How to detect application restart using Forever module

I have an application with a cluster and Forever. I want to save information from workers before shutting down or restarting the application. So I use process.on ('SIGINT') and this works fine for CTRL + C.

But I'm stuck with Forever. Is it possible that somehow the application was restarted by Forever? Is there any signal about this?

+5
source share
4 answers

This problem is quite old, but for those who have not seen it, the latest versions forever support --killSignal (this was added in December 2013), so you can use an example --killSignal=SIGUSR2and catch this signal withprocess.on('SIGUSR2', func)

+3
source

Forever SIGKILL, https://github.com/nodejitsu/forever-monitor/blob/master/lib/forever-monitor/monitor.js#L353

, process.on('SIGKILL', onStop); process.on('SIGINT', onStop);, , kill https://github.com/nodejitsu/forever-monitor/blob/master/lib/forever-monitor/common.js#L45, 'SIGTERM ', process.on('SIGTERM', onStop).

0

kill -s SIGUSR1 <pid> . node process.on('SIGUSR1').

kill -s SIGUSR1 <pid>
forever restart test.js
0

forever --killSignal, (, SIGINT), process.on('SIGINT',...), . , console.log , , , .

0
source

All Articles