{"action":"created","issue":{"url":"https://api.github.com/repos/Unitech/PM2/issues/1036","labels_url":"https://api.github.com/repos/Unitech/PM2/issues/1036/labels{/name}","comments_url":"https://api.github.com/repos/Unitech/PM2/issues/1036/comments","events_url":"https://api.github.com/repos/Unitech/PM2/issues/1036/events","html_url":"https://github.com/Unitech/PM2/issues/1036","id":58770197,"number":1036,"title":"pm2 now kills detached processes (as of 0.12.2)","user":{"login":"ryanbmilbourne","id":5648689,"avatar_url":"https://avatars.githubusercontent.com/u/5648689?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanbmilbourne","html_url":"https://github.com/ryanbmilbourne","followers_url":"https://api.github.com/users/ryanbmilbourne/followers","following_url":"https://api.github.com/users/ryanbmilbourne/following{/other_user}","gists_url":"https://api.github.com/users/ryanbmilbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanbmilbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanbmilbourne/subscriptions","organizations_url":"https://api.github.com/users/ryanbmilbourne/orgs","repos_url":"https://api.github.com/users/ryanbmilbourne/repos","events_url":"https://api.github.com/users/ryanbmilbourne/events{/privacy}","received_events_url":"https://api.github.com/users/ryanbmilbourne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"soyuka","id":1321971,"avatar_url":"https://avatars.githubusercontent.com/u/1321971?v=3","gravatar_id":"","url":"https://api.github.com/users/soyuka","html_url":"https://github.com/soyuka","followers_url":"https://api.github.com/users/soyuka/followers","following_url":"https://api.github.com/users/soyuka/following{/other_user}","gists_url":"https://api.github.com/users/soyuka/gists{/gist_id}","starred_url":"https://api.github.com/users/soyuka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soyuka/subscriptions","organizations_url":"https://api.github.com/users/soyuka/orgs","repos_url":"https://api.github.com/users/soyuka/repos","events_url":"https://api.github.com/users/soyuka/events{/privacy}","received_events_url":"https://api.github.com/users/soyuka/received_events","type":"User","site_admin":false},"milestone":null,"comments":21,"created_at":"2015-02-24T17:14:26Z","updated_at":"2015-06-24T15:20:15Z","closed_at":null,"body":"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. \r\n\r\nIt looks to me like this is directly related to the addition of the new TreeKill system (https://github.com/Unitech/PM2/commit/fe92e71f7d3629fcea4e804fcfd9cec41e5fb76d) in 0.12.2.  See lines 69-70 of TreeKill:\r\n``` javascript\r\n  var args = downgradePs ? '-eo pid,ppid | grep -w ' : '-o pid --no-headers --ppid ';\r\n  var ps = exec('ps ' + args + ppid, function(err, stdout, stderr){...}\r\n```\r\nThat 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.\r\n\r\nWould 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."},"comment":{"url":"https://api.github.com/repos/Unitech/PM2/issues/comments/114906560","html_url":"https://github.com/Unitech/PM2/issues/1036#issuecomment-114906560","issue_url":"https://api.github.com/repos/Unitech/PM2/issues/1036","id":114906560,"user":{"login":"ryanbmilbourne","id":5648689,"avatar_url":"https://avatars.githubusercontent.com/u/5648689?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanbmilbourne","html_url":"https://github.com/ryanbmilbourne","followers_url":"https://api.github.com/users/ryanbmilbourne/followers","following_url":"https://api.github.com/users/ryanbmilbourne/following{/other_user}","gists_url":"https://api.github.com/users/ryanbmilbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanbmilbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanbmilbourne/subscriptions","organizations_url":"https://api.github.com/users/ryanbmilbourne/orgs","repos_url":"https://api.github.com/users/ryanbmilbourne/repos","events_url":"https://api.github.com/users/ryanbmilbourne/events{/privacy}","received_events_url":"https://api.github.com/users/ryanbmilbourne/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T15:20:15Z","updated_at":"2015-06-24T15:20:15Z","body":"Our app is running in `fork_mode`, so we'd be happy with that fix.  For now it sounds like fix isn't in the works for `cluster_mode`, but that doesn't hinder us at all."}}