Is it possible to intercept the default kill
signal and use it as a command for a graceful shutdown? This is for Solaris SMF. The easiest way to have a stoppable service that I have found is to set :kill
as the shutdown script and then to add a shutdown hook in Java. In this case, I want to do it for Node.JS. How should I do it?
Edit: The purpose is to
- Stop receiving new requests.
- Give existing callbacks a few seconds to finish.
- Write some information to stderr.
@alienhard's first suggestion was to use process.on('exit'...
but it seems that I would not be able to accomplish number 2 with this method.