This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gracefulClusterShutdown = (signal: NodeJS.Signals) => async () => { | |
if (this.shutdownInProgress) | |
return | |
this.shutdownInProgress = true | |
this.hasCleanWorkerExit = true | |
log.info(`Got ${signal} on ${this.processStr}. Graceful shutdown start at ${new Date().toISOString()}`) | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as cluster from 'cluster' | |
class Master { | |
private shutdownInProgress: boolean = false | |
private hasCleanWorkerExit: boolean = true | |
private processStr = `${cluster.isMaster ? "master" : "worker"} process ${process.pid}` | |
gracefulClusterShutdown = (signal: NodeJS.Signals) => async () => { | |
//defined in worker-shutdown.ts (https://gist.github.com/Dante-101/de2fbd5071bec0c0647f5c9fa1cfa179) |