|
|
@ -178,8 +178,9 @@ on more than one address. |
|
|
|
|
|
|
|
* `worker` {Worker object} |
|
|
|
|
|
|
|
When a workers IPC channel has disconnected this event is emitted. This will happen |
|
|
|
when the worker dies, usually after calling `.destroy()`. |
|
|
|
When a workers IPC channel has disconnected this event is emitted. |
|
|
|
This will happen when the worker dies, usually after calling |
|
|
|
`.kill()`. |
|
|
|
|
|
|
|
When calling `.disconnect()`, there may be a delay between the |
|
|
|
`disconnect` and `exit` events. This event can be used to detect if |
|
|
@ -323,8 +324,9 @@ See: [Child Process module](child_process.html) |
|
|
|
|
|
|
|
* {Boolean} |
|
|
|
|
|
|
|
This property is a boolean. It is set when a worker dies after calling `.destroy()` |
|
|
|
or immediately after calling the `.disconnect()` method. Until then it is `undefined`. |
|
|
|
This property is a boolean. It is set when a worker dies after calling |
|
|
|
`.kill()` or immediately after calling the `.disconnect()` method. |
|
|
|
Until then it is `undefined`. |
|
|
|
|
|
|
|
### worker.send(message, [sendHandle]) |
|
|
|
|
|
|
@ -348,7 +350,10 @@ This example will echo back all messages from the master: |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
### worker.destroy() |
|
|
|
### worker.kill([signal='SIGTERM']) |
|
|
|
|
|
|
|
* `signal` {String} Name of the kill signal to send to the worker |
|
|
|
process. |
|
|
|
|
|
|
|
This function will kill the worker, and inform the master to not spawn a |
|
|
|
new worker. The boolean `suicide` lets you distinguish between voluntary |
|
|
@ -360,9 +365,11 @@ and accidental exit. |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// destroy worker |
|
|
|
worker.destroy(); |
|
|
|
// kill worker |
|
|
|
worker.kill(); |
|
|
|
|
|
|
|
This method is aliased as `worker.destroy()` for backwards |
|
|
|
compatibility. |
|
|
|
|
|
|
|
### worker.disconnect() |
|
|
|
|
|
|
@ -375,7 +382,7 @@ the worker finally die. |
|
|
|
|
|
|
|
Because there might be long living connections, it is useful to implement a timeout. |
|
|
|
This example ask the worker to disconnect and after 2 seconds it will destroy the |
|
|
|
server. An alternative would be to execute `worker.destroy()` after 2 seconds, but |
|
|
|
server. An alternative would be to execute `worker.kill()` after 2 seconds, but |
|
|
|
that would normally not allow the worker to do any cleanup if needed. |
|
|
|
|
|
|
|
if (cluster.isMaster) { |
|
|
|