-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pm2 now kills detached processes (as of 0.12.2) #1036
Comments
On further inspection, the versioning of the package json doesn't match the commit history. The package.json commits indicate that treeKill was added around 0.11.0, but the change history indicates the change at 0.12.2. |
Have you tried to do the |
I use 0.10.8 works just fine, 0.11.0 does not. |
@Unitech can't we add an option to prevent killing the whole tree? I've tried this out and indeed detached process is beeing killed along with the main process. See https://gist.github.com/soyuka/ca813a8baf1c8efb7974 |
Ok if it's impossible to detach completely a process to avoid killing it, this option worth it |
@Unitech I think a good way forward would be to allow this to be configured at the application level: Thoughts? |
@ryanbmilbourne That's exactly what we were going to do :) |
I think that we should never kill detached processes, that's why they are detached in a way... See my commit, we could easily get rid of TreeKill, or it could be a non-default behavior to kill detached processes along with the main process. At the current status of the We could also bring a way to never kill any childs ( Thoughts? |
Personally, I'm of the opinion that we should kill the parent and let the OS decide how the children live or die. Using a blunderbuss like TreeKill to kill children seems a little...over the top, as it kills ALL children regardless of how they're tied to the parent. I agree with @soyuka that the tree kill should be the non-default. |
@ryanbmilbourne I agree with you. I made a new branch with a simple and cleaner solution that will kill the tree except detached child processes. |
👍 @soyuka Any hope of that being pushed into npm anytime soon? |
Yes it will be published soon :) |
So, @ryanbmilbourne I have this working with the fork mode but I have an issue with the cluster.
This sucks, I'm searching for a solution but it might take a few hours debugging. I don't know if I'll be able to fix it but I'll surely try! |
Great, thank you so much for the quick turnaround. I'll modify my modules' package.json files to look to your repo for the dependency until the PR issue is resolved and the code is merged into the release branch. |
So, little update on this. The cluster mode is using If we could build our own cluster we would be able to fix this but so far, no solution on the cluster mode. If you want I can implement it for the |
@soyuka Any update on your issues with cluster? We were still hoping to see this fix get merged in eventually... |
Sadly we can't have a clean fix for the |
@ryanbmilbourne If your app is running in fork mode, we can easily fix that like this : if (app.mode == 'cluster')
treeKill(pid);
else
process.kill(-(pid), 'SIGINT'); |
My two cents: |
Our app is running in |
You can already use it |
Great, I'll get the dev branch running on our test servers. Thanks for the awesome project. |
@jshkurti What about adding an option to not kill child processes? |
Is this really still an issue, 4 years later? Edit: pass |
实际上,我找到了他们的解决方案:https://github.com/Unitech/pm2/blob/master/examples/treekill/process.json 但这太 shit 了(原谅我,毕竟这浪费了我太多心力),官方文档上似乎没有任何地方提到此特性,更没有提到这个配置,我整整找了四个小时,才找到这里,还得在全仓库搜索关键字才找到这个配置 |
今天我上官网文档还是没有看到配置项有这一条,我用google搜索关键字:pm2 stop kill sub process,在stack overflow 找到了答案 |
I have pm2 managing a node daemon that spawns worker processes as detached children. The idea was that if the daemon was killed or restarted (after an upgrade, for example) the workers would continue working and publishing to the pub/sub system they work with. After upgrading to the latest version from 0.10.x, I noticed that pm2 was killing my detached workers as well as the daemon it was managing.
It looks to me like this is directly related to the addition of the new TreeKill system (fe92e71) in 0.12.2. See lines 69-70 of TreeKill:
That ps command will return the list of all children with that ppid, which, unfortunately, includes children that are detached so that they can live beyond the death of the parent that spawned them. Rather than sending a signal to the parent and relying on it to clean up the children, it looks like pm2 is now sending
SIGTERM
to all processes in the tree.Would there be support for an option or config to have pm2 kill processes in the older manner as opposed to this new(er) KillTree method? It seems to me like there'd be support to kill the parent and have it clean up its children as it sees fit rather than use the nuclear option.
The text was updated successfully, but these errors were encountered: