1

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

Thanks.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370

2 Answers2

2

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
  • 9,550
  • 1
  • 29
  • 22
1

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">
<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!

  • 1
    You might want to look into using GOD to manage your rails processes. More info here: http://ezinearticles.com/?Why-Rails-Developers-Need-God&id=845672 – jonnii Sep 04 '09 at 00:23
  • I also need solution for my El Capitan. my app in /Users/myuser/myapp and I created start.sh left in /Users/myuser/myapp. with following command cd /Users/myuser/myapp ; rails s but not work. Could you give some sample to start up / Thanks P Kul – PKul Jun 16 '16 at 17:30