Skip to content

Instantly share code, notes, and snippets.

@thapakazi
Forked from zacksiri/app_name.conf
Created August 12, 2014 10:42
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 thapakazi/c53670233927de967d05 to your computer and use it in GitHub Desktop.
Save thapakazi/c53670233927de967d05 to your computer and use it in GitHub Desktop.
#/etc/init/change_this_to_your_app_name.conf
description "App Name"
author "Admin Name <admin@app.com>"
start on virtual-filesystems
stop on runlevel [06]
env PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/bin:/usr/bin:/bin
env RAILS_ENV=staging # what environment
env RACK_ENV=staging # what environment
setuid deployer # linux user
setgid admin # group
chdir /opt/apps/app_name
pre-start script
exec /usr/local/rbenv/shims/unicorn -D -c /opt/apps/app_name/config/unicorn.rb --env staging
end script
post-stop script
exec kill `cat /tmp/unicorn.app_name.pid`
end script
@thapakazi
Copy link
Author

/etc/init/unicorn.conf

description "Unicorn"
author "devops@baremetal.juskiding"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 3 30

env RAILS_ENV=staging

setuid stag-user # linux user
setgid stag-group # group

chdir /staging/code/

script
exec sudo su - stag-user -c "cd /staging/code; /usr/local/rvm/bin/rvm-shell 'ruby-2.0.0-p353' -c 'bundle exec unicorn -c config/unicorn.rb -E stag'"
end script

post-stop script
exec kill cat /tmp/pids/unicorn.pid
end script

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