'online' 事件
worker
<cluster.Worker>
衍生新的工作进程之后,工作进程应该使用在线消息进行响应。
当主进程接收到在线消息时,它将触发此事件。
'fork'
和 'online'
的区别在于主进程衍生工作进程时触发衍生,而 'online'
在工作进程运行时触发。
cluster.on('online', (worker) => {
console.log('Yay, the worker responded after it was forked');
});
worker
<cluster.Worker>
After forking a new worker, the worker should respond with an online message.
When the primary receives an online message it will emit this event.
The difference between 'fork'
and 'online'
is that fork is emitted when the
primary forks a worker, and 'online'
is emitted when the worker is running.
cluster.on('online', (worker) => {
console.log('Yay, the worker responded after it was forked');
});