mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
87 lines
2.3 KiB
Text
87 lines
2.3 KiB
Text
# /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.
|
||
#
|
||
# See workers.conf for how to manage all Sidekiq instances at once.
|
||
#
|
||
# Save this config as /etc/init/sidekiq.conf then mange sidekiq with:
|
||
# 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!)
|
||
# setuid apps
|
||
# setgid apps
|
||
|
||
respawn
|
||
respawn limit 3 30
|
||
|
||
# TERM and USR1 are sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns.
|
||
normal exit 0 TERM USR1
|
||
|
||
instance ${app}-${index}
|
||
|
||
script
|
||
# this script runs in /bin/sh by default
|
||
# respawn as bash so we can source in rbenv
|
||
exec /bin/bash <<EOT
|
||
# uncomment to use syslog for logging
|
||
# exec &> /dev/kmsg
|
||
|
||
export HOME=/home/apps
|
||
|
||
# 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"
|
||
|
||
cd $app
|
||
exec bundle exec sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/sidekiq/${index}.pid
|
||
EOT
|
||
end script
|
||
|
||
pre-stop script
|
||
# this script runs in /bin/sh by default
|
||
# respawn as bash so we can source in rbenv
|
||
exec /bin/bash <<EOT
|
||
# uncomment to use syslog for logging
|
||
# exec &> /dev/kmsg
|
||
|
||
export HOME=/home/apps
|
||
|
||
# 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"
|
||
|
||
cd $app
|
||
exec bundle exec sidekiqctl stop tmp/sidekiq/${index}.pid
|
||
EOT
|
||
end script
|