remy/nodemon — pull request #94 by dervsh (2012-05-03 11:54:48+00:00)
Title: Introduce --graceful [n] switch

Following commit introduces new --graceful [n] switch to nodemon. It will let clean shutdown not only on restart caused by code restarts but also on nodemon shutting down.

If --graceful switch will be used without any arguments, once nodemon receives SIGINT (eg. Ctrl-C) it will send SIGUSR2 to the running script and wait for default 5 seconds for the script to graceful shutdown.

It is also possible to change wait time - eg. if nodemon will be started with --graceful 10 - it will wait for 10 seconds.

If the switch wont be used, default nodemon behavior will be the same as before.

In order for --graceful to work, running script must handle SIGINT (because of signal propagation) and SIGUSR2 (initializing actual shutdown). If running script is cluster based, it is advised to handle SIGINT in worker processes too.

I'll be very glad if the patch will be merged to nodemon. Im working on AMQP and In my case unclean shutdowns might be a bit devastating for app nodes intercommunication.