Skip to content

Commit

Permalink
doc: specify cluster worker.kill() caveat
Browse files Browse the repository at this point in the history
worker.kill() relies on a graceful disconnect, which might not
always be possible. This commit calls this out in the docs, and
specifies worker.process.kill() as a non-graceful alternative.

PR-URL: #23165
Fixes: #22703
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Oct 5, 2018
1 parent 8f5fb6f commit 5836b9f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ This function will kill the worker. In the master, it does this by disconnecting
the `worker.process`, and once disconnected, killing with `signal`. In the
worker, it does it by disconnecting the channel, and then exiting with code `0`.

Because `kill()` attempts to gracefully disconnect the worker process, it is
susceptible to waiting indefinitely for the disconnect to complete. For example,
if the worker enters an infinite loop, a graceful disconnect will never occur.
If the graceful disconnect behavior is not needed, use `worker.process.kill()`.

Causes `.exitedAfterDisconnect` to be set.

This method is aliased as `worker.destroy()` for backwards compatibility.
Expand Down

0 comments on commit 5836b9f

Please sign in to comment.