exit event (Cluster)

Event: 'exit'

  • worker <cluster.Worker>
  • 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.

When any of the workers die the cluster module will emit the 'exit' event.

This can be used to restart the worker by calling .fork() again.

cluster.on('exit', (worker, code, signal) => {
  console.log('worker %d died (%s). restarting...',
    worker.process.pid, signal || code);
  cluster.fork();
});

See child_process event: 'exit'.

doc_Nodejs
2016-04-30 04:39:31
Comments
Leave a Comment

Please login to continue.