Is there any port of start-stop-daemon for OS X?

I am trying to use some init.d script under OS X and I while some are just working properly, I discovered quite a few that to rely on /sbin/start-stop-daemon and I am looking for a port of it for OS X.

Any ideas?

Note, I know that OS X does not have support for init.d but there is nothing stoping you from using it to start/stop some services. It is much easier to install things like postgres, nginx using brew and control them using the usual service name start|stop|restart.


You need to look at launchd which uses *.plist setup files in:

/Library/LaunchAgents/, /Library/LaunchDaemons/ and ~/Library/LaunchAgents/

Under /System/Library/LaunchAgents/ and /System/Library/LaunchDaemons/ are the ones provided by Mac OS X.

When you e.g. install postgresql form Macports, there will also be installed an org.macports.postgresql93-server.plist file under /Library/LaunchDaemons/ (it is a link to a .plist file which is installed under /opt/local/etc/LaunchDaemons/org.macports.postgresql93-server), but the daemon isn't enabled at install.

The content of this .plist file is (the key <key>Disabled</key><true/> need to be set to false, if you need to enable the daemon):

<?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>Label</key><string>org.macports.postgresql93-server</string>
<key>ProgramArguments</key>
<array>
    <string>/opt/local/bin/daemondo</string>
    <string>--label=postgresql93-server</string>
    <string>--start-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
    <string>start</string>
    <string>;</string>
    <string>--stop-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
    <string>stop</string>
    <string>;</string>
    <string>--restart-cmd</string>
    <string>/opt/local/etc/LaunchDaemons/org.macports.postgresql93-server/postgresql93-server.wrapper</string>
    <string>restart</string>
    <string>;</string>
    <string>--pid=none</string>
</array>
<key>Debug</key><false/>
<key>Disabled</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>

Rene Larsen's answer holds the secret but it was not called out. What you want to do is to install MacPorts, which provides the daemondo program (installed to /opt/local/bin/daemondo on my system).

From the help screen: "daemondo is a wrapper program that runs daemons." It appears to provide arguments and functionality similar to start-stop-daemon.