Skip to content

Instantly share code, notes, and snippets.

@zohararad
Created November 21, 2014 10:11
Show Gist options
  • Save zohararad/8ffee850347f7d0b8a16 to your computer and use it in GitHub Desktop.
Save zohararad/8ffee850347f7d0b8a16 to your computer and use it in GitHub Desktop.
Control several workers from the same master upstart script
description "Some Ruby Worker"
kill timeout 10
respawn
instance $INSTANCE
script
app=/var/deploy/myapp/production/current
pid="$app/tmp/pids/worker-$INSTANCE.pid"
exec start-stop-daemon -S -p $pid -u deploy -g deploy -d $app --exec /usr/bin/env -- APP_ENV=production rake worker:do_something 2>&1
end script
description "Master Worker Init Script"
start on runlevel [2345]
stop on runlevel [06]
pre-start script
for n in $(seq 1 5)
do
/sbin/start some-worker INSTANCE=$n
done
end script
post-stop script
for n in `initctl list|grep "^some-worker "|awk '{print $2}'|tr -d ')'|tr -d '('`
do
/sbin/stop some-worker INSTANCE=$n
done
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment