-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Cluster worker.kill(signal) does not pass the signal parameter #6042
Comments
I think this is a bug. worker.kill() sets .suicide in the master, but it doesn't send suicide to the worker, so master/worker opinion of suicide is not in sync. Since master does a process.disconnect() before it does a process.kill(), the workers sees an unexpected disconnect, and exits before the signal gets a chance to be delivered. Probably fix is for master to send a suicide message before doing a worker.process.disconnect(), similar to what the worker does when kill is called in the child. |
Been talking it over with Sam and I'm leaning towards removing Worker#kill(). It's an alias for Worker#destroy() right now but it:
Which is weird because e.g. Other committers, thoughts? |
@bnoordhuis +1 from me. |
@bnoordhuis, since worker.destroy === worker.kill right now, all the problems you enumerate exist for destroy as much as for kill. Did you intend to change it so it can only be used to terminate the worker? I suggest changing worker.kill() to be an alias to worker.process.kill(), and removing worker.destroy(). This would parallel how worker.send() is an alias to worker.process.send(). I'm also OK with simply removing both .kill and .destroy, though I think leaving the documented .kill around is a bit friendlier to existing code. Reasons:
I'm happy to implement this (yeah, its only 2 lines of code, but then there are all the docs and tests...), if you all want it. |
@sam-github @bnoordhuis ... is this resolved? |
Not resolved. |
Regarding a workaround, how safe is it to kill a child process via |
doing so just sends the signal. whether that is "safe" or not just depends on whether the signal does what you want, which is up to your code. worker.process and its methods are public APIs of worker/cluster, and can be used as doced |
Thank you for the quick response @sam-github |
When calling worker.kill(signal) and passing a signal, the signal does not get sent to worker process as per documentation.
http://nodejs.org/api/cluster.html#cluster_worker_kill_signal_sigterm
Example:
The text was updated successfully, but these errors were encountered: