Created
July 27, 2012 13:40
-
-
Save witscher/3188098 to your computer and use it in GitHub Desktop.
Upstart script for unicorn, bundler and a user contained rvm installation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script works with upstart < 1.4 (Ubuntu 10.04 LTS)