Created
November 21, 2014 10:11
-
-
Save zohararad/8ffee850347f7d0b8a16 to your computer and use it in GitHub Desktop.
Control several workers from the same master upstart script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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