I am running multiple instances of a worker as described in this answer: Starting multiple upstart instances automatically
Question: Can I restart all instan
In worker.conf you just need to change this line:
stop on shutdown
To:
stop on stopping my-workers
And change my-workers.conf to use pre-start instead of script:
pre-start script
for i in `seq 1 $NUM_WORKERS`
do
start worker N=$i
done
end script
Now my-workers will keep state: since the work happens in pre-start, the my-workers main process won't exist and so won't exit. stop on stopping my-workers causes the workers to stop whenever my-workers is stopped. Then of course when it starts up again it will start the workers again.
(FYI, stop on shutdown does nothing, as shutdown is not a system event. man upstart-events for all the defined events) so you should also change my-workers to stop on runlevel [06]