Skip to content

Instantly share code, notes, and snippets.

@mtmcfarl
Forked from witscher/unicorn.conf
Created October 17, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtmcfarl/6f570197fead47fdc002 to your computer and use it in GitHub Desktop.
Save mtmcfarl/6f570197fead47fdc002 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment