views:

198

answers:

2

Hi,

how can I make ruby on rails app start automatically on Mac OS X Server boot?

Thanks.

+1  A: 

ok, found the answer.

first create file in /Library/LaunchDaemons/my.startup.rails.app.plist

it's an xml file with a structure like 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"&gt;
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>my.startup.rails.app</string>
    <key>ProgramArguments</key>
    <array>
     <string>/Library/WebServer/start.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>86400</integer>
</dict>
</plist>

where /Library/WebServer/start.sh contains shell script to launch the rails app.

Then make it launch when your computer boots:

sudo launchctl load -w /Library/LaunchDaemons/my.startup.rails.app.plist

Done!

jonnii
+1  A: 

I'd recommend using passenger, it makes all these headaches away. It even has an OS-X control panel, made my life a whole lot easier.

cwninja