Skip to content

Instantly share code, notes, and snippets.

@bobeckert
Created October 3, 2014 20:19
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 bobeckert/775708074e39290047aa to your computer and use it in GitHub Desktop.
Save bobeckert/775708074e39290047aa to your computer and use it in GitHub Desktop.
# /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 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 "Sidekiq Background Worker"
# no "start on", we don't want to automatically start
stop on (stopping workers_backoffice or runlevel [06])
# change to match your deployment user
setuid deploy
setgid deploy
respawn
respawn limit 3 30
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<EOT
# use syslog for logging
exec &> /dev/kmsg
# pull in system rvm
export HOME=/home/deploy
source /etc/profile.d/rvm.sh
source /srv/backoffice/shared/config/env
cd /srv/backoffice/current
exec bin/sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/pids/sidekiq-${index}.pid
EOT
@JamesAwesome
Copy link

  • double quotes on line 28 around $index
  • Line 33 should say this runs in dash because /bin/sh is a symlink and that's important, check that /bin/sh is dash first, but pretty sure it is
  • Line 37 is uh... i mean if you say syslog is important, but upstart does log to /var/log/upstart just fine and any output you need should probably be parsed from there... that's just confusing and could make troubleshooting a bitch, however it's not technically "wrong"
  • Line 44 cd's only to make the next line shorter?
  • Line 45 doesn't escape anything properly and is very error prone.

@JamesAwesome
Copy link

doesn't end script need to happen? http://upstart.ubuntu.com/cookbook/#script

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