restart workers on sigusr2

This commit is contained in:
Evert Prants 2017-08-31 12:53:05 +03:00
parent 37f6ca5eda
commit 12f89ade59
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
1 changed files with 14 additions and 0 deletions

View File

@ -112,3 +112,17 @@ cluster.on('exit', (worker, code, signal) => {
})
initialize()
process.stdin.resume()
process.on('SIGUSR2', () => {
console.log('Received SIGUSR2. Restarting workers.')
if (workers.length) {
for (let i in workers) {
workers[i].send('stop')
}
}
spawnWorkers()
})