Skip to content

Instantly share code, notes, and snippets.

@witscher
Created July 27, 2012 13:40

Revisions

  1. witscher created this gist Jul 27, 2012.
    20 changes: 20 additions & 0 deletions unicorn.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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`