Skip to content

Instantly share code, notes, and snippets.

@skogsmaskin
Last active August 29, 2015 14:00
Show Gist options
  • Save skogsmaskin/11261988 to your computer and use it in GitHub Desktop.
Save skogsmaskin/11261988 to your computer and use it in GitHub Desktop.
How to start Unicorn on Mac OS X via LaunchAgents (LaunchCtl)

How to start Unicorn on Mac OS X via LaunchAgents (LaunchCtl)

First make a bootup bundle for RVM.

$ rvm wrapper $(rvm current) bootup bundle

Add this xml to ~/Library/LaunchAgents/apps.myapp.unicorn.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>apps.myapp.unicorn</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/username/.rvm/bin/bootup_bundle</string>
    <string>exec</string>
    <string>unicorn</string>
    <string>-c</string>
    <string>/srv/myapp/unicorn.rb</string>
    <string>-E</string>
    <string>development</string>
  </array>
  <key>WorkingDirectory</key>
  <string>/srv/myapp</string>
  <key>RunAtLoad</key>
  <true/>
  <key>StandardErrorPath</key><string>/srv/myapp/log/unicorn.stderr.log</string>
  <key>StandardOutPath</key><string>/srv/myapp/log/unicorn.stdout.log</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment