exit event (Worker)

Event: 'exit'

  • code <Number> the exit code, if it exited normally.
  • signal <String> the name of the signal (eg. 'SIGHUP') that caused the process to be killed.

Similar to the cluster.on('exit') event, but specific to this worker.

const worker = cluster.fork();
worker.on('exit', (code, signal) => {
  if( signal ) {
    console.log(`worker was killed by signal: ${signal}`);
  } else if( code !== 0 ) {
    console.log(`worker exited with error code: ${code}`);
  } else {
    console.log('worker success!');
  }
});
doc_Nodejs
2016-04-30 04:39:31
Comments
Leave a Comment

Please login to continue.