Skip to content

Instantly share code, notes, and snippets.

@witscher
Created July 27, 2012 13:40
Show Gist options
  • Save witscher/3188098 to your computer and use it in GitHub Desktop.
Save witscher/3188098 to your computer and use it in GitHub Desktop.
Upstart script for unicorn, bundler and a user contained rvm installation
description "Unicorn"
# starting unicorn with bundler, and a user contained rvm:
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
chdir /path/to/current
env RAILS_ENV=production
# as the unicorn master detaches itself (and you probably want to restart it safely with capistrano), a working solution is to use the pre-start and post-stop flags:
pre-start script
exec su - <app-user> -c "cd /path/to/current; source ~/.rvm/scripts/rvm; ~/.rvm/bin/rvm-shell -c 'bundle exec unicorn -c config/unicorn.rb -E production -D'"
end script
post-stop exec kill `cat /path/to/unicorn.pid`
@witscher
Copy link
Author

this script works with upstart < 1.4 (Ubuntu 10.04 LTS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment