Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Created May 16, 2014 18:58
Show Gist options
  • Select an option

  • Save RobinDaugherty/8d73265fff37360e0d6d to your computer and use it in GitHub Desktop.

Select an option

Save RobinDaugherty/8d73265fff37360e0d6d to your computer and use it in GitHub Desktop.
Upstart config for sidekiq workers
# /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 aperture-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 index=0
# sudo stop sidekiq index=0
# sudo status sidekiq index=0
#
# or use the service command:
# sudo service sidekiq {start,stop,restart,status}
#
description "Individual Aperture background workers"
# no "start on", we don't want to automatically start
stop on stopping aperture-workers
# change to match your deployment user
setuid deploy
setgid deployers
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 $worker
script
# this script runs in /bin/sh by default
# respawn as bash
/bin/bash <<EOT
cd /data/aperture/current
exec bundle exec sidekiq -i ${index} -e production -C config/sidekiq_${config_name}.yml -P tmp/pids/sidekiq-${index}.pid
EOT
end script
# /etc/init/workers.conf - manage a set of Sidekiqs
# 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 sidekiq.conf for how to manage a single Sidekiq instance.
#
# Use "stop workers" to stop all Sidekiq instances.
# Use "start workers" to start all instances.
# Use "restart workers" to restart all instances.
# Crazy, right?
#
description "Aperture background workers"
# This starts upon bootup and stops on shutdown
start on runlevel [2345]
stop on runlevel [06]
# List of sidekiq worker configs, there will be one worker for each
env WORKERS=(high posting default sunspot)
pre-start script
for index in "${!WORKERS[*]}"
do
start aperture-worker index=$index worker=${array[$index]}
done
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment