1

How can I create a init script that starts (and tracks) the new process before the old is completely terminated at restart?

I am developing a node.js service that needs to be able to restart gracefully, for example at deploy of a new version. The problem is that the service has some long-running tasks that need to complete before the service process can be shutdown completely, but the new process should be launched immediatly.

Normally, when developing a service, I would create a simple upstart-init-script starting a service as a unprivileged user, run the deploy as the same unprivileged user and at the end of the deploy script send a SIGINT to shutdown the service. Upstart would then detect that the service has terminated and restart from the newly deployed code.

This time though the service can take as much as an hour to shutdown after receiving the SIGINT and thus I need to run several processes in parallell and I do not think upstart is designed for this.

I guess I could skip upstart and just launch the new process in the deploy script and detach it, but that would be mean I would loose the automatic boot/restart/start/stop functionallity upstart provides, so I would prefer not to.

Paso
  • 131
  • 1
  • 4
  • Why is the service process running these tasks? Can't you stick them in the background? – Michael Hampton Aug 13 '14 at 12:41
  • The tasks are codependent and the service process needs to keep track of the tasks state and have lots of communication with them. – Paso Aug 13 '14 at 13:30

0 Answers0