4

I'm trying to run a service in 'ondemand' mode, but I can't even get launchctl to register the service.

$ launchctl load /Library/LaunchDaemons/org.fossil-scm.fossil.plist
bind(): Permission denied
bind(): Permission denied
$

As I'm getting a double 'bind' error I believe I've done something wrong with the Sockets configuration in the attached plist.

How do I setup an network(port 8080) launched on-demand service with launchd?

The apple dev documentation for launchd/launchctl/launchd.plist, TN2083 Daemons and Agents, and 'Creating launchd Daemons and Agents' is a bit thin on this.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>inetdCompatibility</key>
 <dict/>
 <key>Label</key>
 <string>org.fossil-scm.fossil</string>
 <key>KeepAlive</key>
 <false/>
 <key>RunAtLoad</key>
 <false/>
 <key>ProgramArguments</key>
 <array>
  <string>/usr/local/fossil/bin/fossil</string>
  <string>http</string>
  <string>/Users/spdegabrielle/fossil-local-repository/myclone.fossil</string>
 </array>
 <key>Sockets</key>
 <dict>
                <key>Listeners</key>
                <array>
                <dict>
                        <key>SockFamily</key>
                        <string>IPv4</string>
                        <key>SockServiceName</key>
                        <string>http-alt</string>
                        <key>SockType</key>
                        <string>stream</string>
                </dict>
                <dict>
                        <key>SockFamily</key>
                        <string>IPv6</string>
                        <key>SockServiceName</key>
                        <string>http-alt</string>
                        <key>SockType</key>
                        <string>stream</string>
                </dict>
                </array>
        </dict>
 <key>UserName</key>
 <string>root</string>
</dict>
</plist>

Note: UserName was added as I thought perhaps I needed to run is in /Library/LaunchDaemons/, rather than my preferred location ~/Library/LaunchAgents

I'm wanting to associate the launchagent with port 8080, but it seems http-alt expects port 591:

$ sudo cat /etc/services |grep http-alt
http-alt    591/udp     # FileMaker, Inc. - HTTP Alternate (see Port 80)
http-alt    591/tcp     # FileMaker, Inc. - HTTP Alternate (see Port 80)
http-alt    8008/udp     # HTTP Alternate
http-alt    8008/tcp     # HTTP Alternate
http-alt    8080/udp     # HTTP Alternate (see port 80)
http-alt    8080/tcp     # HTTP Alternate (see port 80)

The default of http-alt using the name is Filemaker (6!), simple change the SockServiceName to 8080 or you port of choice.

Stephen
  • 173
  • 1
  • 3
  • 8

1 Answers1

3

I see that you're trying to attach the process to port 591 (http-alt).

In Mac OS X (as any other Unix) a regular user can't attach any process to ports under 1024, only root can do such operations.

Your guess is right, move the plist over to the general dir at in /System/Library/LaunchDaemons (since this is listening in a socket it makes sense for the plist to be there) and sudo launchctl load the process

lynxman
  • 9,157
  • 3
  • 24
  • 28
  • $ sudo cat /etc/services |grep http-alt http-alt 591/udp # FileMaker, Inc. - HTTP Alternate (see Port 80) http-alt 591/tcp # FileMaker, Inc. - HTTP Alternate (see Port 80) http-alt 8008/udp # HTTP Alternate http-alt 8008/tcp # HTTP Alternate http-alt 8080/udp # HTTP Alternate (see port 80) http-alt 8080/tcp # HTTP Alternate (see port 80) – Stephen Jan 25 '11 at 17:00
  • damn - I need 8080, not 591. – Stephen Jan 25 '11 at 17:01
  • +1 I wish I could give you 'answered'! your response is a breakthrough! – Stephen Jan 25 '11 at 17:08
  • answered - I'll ask a new question. – Stephen Jan 25 '11 at 18:21
  • Cool! Happy to see it worked – lynxman Jan 25 '11 at 19:17