Restarting Upstart instance processes

后端 未结 1 1883
萌比男神i
萌比男神i 2020-12-23 07:57

I am running multiple instances of a worker as described in this answer: Starting multiple upstart instances automatically

Question: Can I restart all instan

1条回答
  •  执笔经年
    2020-12-23 08:18

    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]

    0 讨论(0)
提交回复
热议问题