Skip to content

Instantly share code, notes, and snippets.

@kugaevsky
Last active August 29, 2015 14:22
Show Gist options
  • Save kugaevsky/8931951b5e919f504300 to your computer and use it in GitHub Desktop.
Save kugaevsky/8931951b5e919f504300 to your computer and use it in GitHub Desktop.
Capistrano templates for Unicorn and Sidekiq upstart scripts
#!upstart
description "Upstart Script for a Freefeed sidekiq process"
start on startup
stop on shutdown
respawn
setuid deploy
setgid deploy
chdir <%= "#{deploy_to}/current/" %>
script
/usr/local/rvm/wrappers/ruby-2.2.1@freefeed/bundle exec sidekiq -e <%= fetch(:stage) %>
flock -x 0 < <%= deploy_to %>/current/tmp/pids/sidekiq.pid.lock
end script
pre-stop script
exec /bin/bash <<EOT
exec kill -QUIT `cat <%= shared_path %>/tmp/pids/sidekiq.pid`
EOT
end script
#!upstart
description "Upstart Script for a Freefeed unicorn process"
start on startup
stop on shutdown
respawn
setuid deploy
setgid deploy
reload signal USR2
chdir <%= "#{deploy_to}/current/" %>
script
/usr/local/rvm/wrappers/ruby-2.2.1@freefeed/bundle exec unicorn -c ./config/unicorn.rb --env <%= fetch(:stage) %>
flock -x 0 < <%= fetch(:deploy_to) %>/current/tmp/pids/unicorn.pid.lock
end script
pre-stop script
exec /bin/bash <<EOT
exec kill -QUIT `cat <%= shared_path %>/tmp/pids/unicorn.pid`
EOT
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment