2013-03-09 19:10:59 -03:00
|
|
|
|
# /etc/init/sidekiq.conf - Sidekiq config
|
|
|
|
|
|
|
|
|
|
# This example config should work with Ubuntu 12.04+. It
|
|
|
|
|
# allows you to manage multiple Sidekiq instances with
|
|
|
|
|
# Upstart, Ubuntu's native service management tool.
|
|
|
|
|
#
|
2014-03-24 20:38:11 +01:00
|
|
|
|
# See sidekiq-manager.conf for how to manage all Sidekiq instances at once.
|
2013-03-09 19:10:59 -03:00
|
|
|
|
#
|
2014-10-30 00:45:52 -06:00
|
|
|
|
# Save this config as /etc/init/sidekiq.conf then manage sidekiq with:
|
2013-03-09 19:10:59 -03:00
|
|
|
|
# sudo start sidekiq app=/path/to/app index=0
|
|
|
|
|
# sudo stop sidekiq app=/path/to/app index=0
|
|
|
|
|
# sudo status sidekiq app=/path/to/app index=0
|
|
|
|
|
#
|
|
|
|
|
# or use the service command:
|
|
|
|
|
# sudo service sidekiq {start,stop,restart,status}
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
description "Sidekiq Background Worker"
|
|
|
|
|
|
|
|
|
|
# no "start on", we don't want to automatically start
|
|
|
|
|
stop on (stopping sidekiq-manager or runlevel [06])
|
|
|
|
|
|
|
|
|
|
# change apps to match your deployment user if you want to use this as a less privileged user (recommended!)
|
2014-11-10 14:06:32 -06:00
|
|
|
|
# setuid deploy
|
|
|
|
|
# setgid deploy
|
|
|
|
|
# env HOME=/home/apps
|
2013-03-09 19:10:59 -03:00
|
|
|
|
|
|
|
|
|
respawn
|
|
|
|
|
respawn limit 3 30
|
|
|
|
|
|
2014-07-28 13:50:47 -07:00
|
|
|
|
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns.
|
|
|
|
|
normal exit 0 TERM
|
2013-10-03 11:18:05 -07:00
|
|
|
|
|
2013-03-09 19:10:59 -03:00
|
|
|
|
instance ${app}-${index}
|
|
|
|
|
|
|
|
|
|
script
|
|
|
|
|
# this script runs in /bin/sh by default
|
|
|
|
|
# respawn as bash so we can source in rbenv
|
2014-11-10 14:06:32 -06:00
|
|
|
|
exec /bin/bash <<'EOT'
|
2013-03-09 19:10:59 -03:00
|
|
|
|
# Pick your poison :) Or none if you're using a system wide installed Ruby.
|
|
|
|
|
# rbenv
|
|
|
|
|
# source /home/apps/.bash_profile
|
|
|
|
|
# OR
|
|
|
|
|
# source /home/apps/.profile
|
|
|
|
|
# OR system:
|
|
|
|
|
# source /etc/profile.d/rbenv.sh
|
|
|
|
|
#
|
|
|
|
|
# rvm
|
|
|
|
|
# source /home/apps/.rvm/scripts/rvm
|
|
|
|
|
|
|
|
|
|
logger -t sidekiq "Starting process: $app-$index"
|
|
|
|
|
|
2014-11-10 14:06:32 -06:00
|
|
|
|
# Logs out to /var/log/upstart/sidekiq.log by default
|
|
|
|
|
|
2013-03-09 19:10:59 -03:00
|
|
|
|
cd $app
|
2014-12-05 14:23:17 -07:00
|
|
|
|
exec bundle exec sidekiq -i ${index} -e production -P ${app}/tmp/pids/sidekiq-${index}.pid
|
2013-03-09 19:10:59 -03:00
|
|
|
|
EOT
|
|
|
|
|
end script
|
2013-05-23 11:52:23 -04:00
|
|
|
|
|
|
|
|
|
pre-stop script
|
|
|
|
|
# this script runs in /bin/sh by default
|
|
|
|
|
# respawn as bash so we can source in rbenv
|
2014-11-10 11:40:47 -06:00
|
|
|
|
exec /bin/bash <<'EOT'
|
2013-05-23 11:52:23 -04:00
|
|
|
|
# Pick your poison :) Or none if you're using a system wide installed Ruby.
|
|
|
|
|
# rbenv
|
|
|
|
|
# source /home/apps/.bash_profile
|
|
|
|
|
# OR
|
|
|
|
|
# source /home/apps/.profile
|
|
|
|
|
# OR system:
|
|
|
|
|
# source /etc/profile.d/rbenv.sh
|
|
|
|
|
#
|
|
|
|
|
# rvm
|
|
|
|
|
# source /home/apps/.rvm/scripts/rvm
|
|
|
|
|
|
|
|
|
|
logger -t sidekiq "Stopping process: $app-$index"
|
|
|
|
|
|
2014-11-10 14:06:32 -06:00
|
|
|
|
# Logs out to /var/log/upstart/sidekiq.log by default
|
|
|
|
|
|
2013-05-23 11:52:23 -04:00
|
|
|
|
cd $app
|
2014-12-05 14:23:17 -07:00
|
|
|
|
exec bundle exec sidekiqctl stop ${app}/tmp/pids/sidekiq-${index}.pid 2> /dev/null
|
2013-05-23 11:52:23 -04:00
|
|
|
|
EOT
|
|
|
|
|
end script
|