pm2 is killing detached child processes on watch restart (ie which have been spawned with detached:true, stdio:'ignore', and child.unref().
Is there a way of telling pm2 not to kill the tree of child processes on restart?
pm2 is killing detached child processes on watch restart (ie which have been spawned with detached:true, stdio:'ignore', and child.unref().
Is there a way of telling pm2 not to kill the tree of child processes on restart?
The answer was to put the following in the ecosystem file (main section for app, not under the watch settings):
"treekill": false
I restart my nodejs app from within using the pm2 API. Here is the function I use so that detached child processes are not killed (notice the treekill: false option).
function restartPm2() {
pm2.connect(function(err) {
if (err) {
console.error("PM2 FAILED TO CONNECT:", err);
} else {
pm2.restart('myapp.js', { treekill: false }, function() {});
}
});
pm2.disconnect();
}