Pm2: treekill option has inconsistent behaviour when pm2 is used via json configuration (application declaration)

Created on 29 Aug 2015  路  5Comments  路  Source: Unitech/pm2

Suppose I give the options to pm2 directly in the command line:

pm2 start index.js --name "my-app"

Then the treekill feature will be used (that is, when i call pm2 stop my-app, pm2 will kill all the children). This is the expected behaviour, in my opinion.

However if I use pm2 via json configuration, using the same options from the command line, pm2 won't kill the child processes. That is, if I have a pm2-conf.json like this:

{
  "name": "my-app",
  "script": "index.js",
}

and if I execute

pm2 start pm2-conf.json
pm2 stop my-app

then the child processes will remain alive. To make sure they are killed the json must have the "treekill" property, which isn't even documented in the docs (I found it in lib/schema.json)

{
  "name": "my-app",
  "script": "index.js",
  "treekill": true
}

So I suggest that the "treekill" option should be true by default when pm2 is used via application configuration, as that's the default behaviour when the options are given directly in the command line.

stale

Most helpful comment

I can confirm the json value is entirely ignored. The cli option does work for stop gap. Any updates on this @Unitech ?

All 5 comments

@Unitech the treekill option in json doesn't seem to work. I set it to false.
I start my app via $ pm2 start myapp.json [fork mode]
then $ pm2 restart myapp kills it along with childs.
It works fine if I do pm2 --no-treekill restart myapp though. Why?

I can confirm the json value is entirely ignored. The cli option does work for stop gap. Any updates on this @Unitech ?

@kripplek this is fixed on master after I complained. It's not released to npm yet :/

@ninja- Thanks for the heads up. @Unitech When can we get the npm release updated?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings