Oh, neat. In my tests I was trying to catch Ctrl+C using SIGTERM. My bad. Thanks for the help!
-- Michael Jackson @mjackson On Wed, Jan 30, 2013 at 5:08 PM, Dan Milon <[email protected]> wrote: > You can easily override the default signal handlers. > See http://nodejs.org/docs/latest/api/process.html#process_signal_events > > you could do: > > ``` > function gracefulExit() { > db.close(process.exit) > } > > process.on('SIGINT' gracefulExit).on('SIGTERM', gracefulExit) > ``` > > Obviously it can be more sophisticated, with timeouts, etc. > > danmilon. > > On 01/31/2013 02:59 AM, Michael Jackson wrote: > > It would be really nice to be able to exit a process gracefully on > > SIGINT/SIGTERM. Right now both signals are hardwired to exit with > > a status of 1 (see the SignalExit function in node.cc) without > > emitting the "exit" event on the process object, but I don't see > > why that needs to be the case. > > > > Ideally these signals would be handled just like any other signal. > > The default may be to exit with a 1 status, but it would be nice to > > be able to override this in userland. > > > > A couple of real world use cases: > > > > - Using Ctrl+C in a terminal that is attached to a running process > > - Heroku's dyno manifold issues SIGTERM to processes to let them > > know they are going to be restarted (see > > https://devcenter.heroku.com/articles/ps#graceful-shutdown-with-sigterm > ). > > > > > As it stands now there is no way to ensure that a running server doesn't > > drop open connections during a deploy on Heroku. > > > > What is the reason for the current behavior? Is there any way > > around it for the use cases I've described? > > > > Thanks in advance. > > > > -- Michael Jackson @mjackson > > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: > > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > > > > You received this message because you are subscribed to the Google > > Groups "nodejs" group. To post to this group, send email to > > [email protected] To unsubscribe from this group, send email > > to [email protected] For more options, visit this > > group at http://groups.google.com/group/nodejs?hl=en?hl=en > > > > --- You received this message because you are subscribed to the > > Google Groups "nodejs" group. To unsubscribe from this group and > > stop receiving emails from it, send an email to > > [email protected]. For more options, visit > > https://groups.google.com/groups/opt_out. > > > > > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
