When I use a process (.config.js) file, --node-args given in the command line are not getting passed to the started instances - however, PM2 doesn't throw an error or a warning about this.
It should either pass the CLI options to started instances, overwriting the config file, or issue a warning that the CLI option is not working.
Create a .js file that just logs process.execArgv:
console.log(process.execArgv);
Then create .config.js ecosystem files like this:
// Good
module.exports = {
apps : [{
name : "test_good",
script : "./test.js",
node_args : ["--max-old-space-size=8192"],
autorestart : false,
},
{
name : "test_good2",
script : "./test.js",
node_args : ["--max-old-space-size=8192"],
autorestart : false
},
]}
// Bad
module.exports = {
apps : [{
name : "test_bad",
script : "./test.js",
// node_args : ["--max-old-space-size=8192"],
autorestart : false,
},
{
name : "test_bad2",
script : "./test.js",
// node_args : ["--max-old-space-size=8192"],
autorestart : false
},
]}
then start PM2:
# setting in the config file
pm2 start test_good.config.js --only test_good
# this should overwrite the setting in the config file
pm2 start test_overwrite.config.js --node-args="--max-old-space-size=4096"
# no setting in config file, CLI parameter not getting passed
pm2 start test_bad.config.js --only test_bad --node-args="--max-old-space-size=8192"
See the attachment: pm2test.zip.
Please run the following command (available on PM2 >= 2.6)
$ pm2 report
===============================================================================
--- PM2 REPORT (Tue Apr 10 2018 10:53:47 GMT+0200 (CEST)) ---------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 2.10.2
node version : 8.11.1
node path : /home/gombosg/.npm-global/bin/pm2
argv : /usr/bin/node,/home/gombosg/.npm-global/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : gombosg
uid : 1000
gid : 1000
uptime : 22min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 2.10.2
node version : 8.11.1
node path : undefined
argv : /usr/bin/node,/home/gombosg/.npm-global/bin/pm2,report
argv0 : node
user : gombosg
uid : 1000
gid : 1000
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
cpus nb : 4
freemem : 385179648
totalmem : 8231157760
home : /home/gombosg
===============================================================================
--- PM2 list -----------------------------------------------
โโโโโโโโโโโโโโโโโโฌโโโโโฌโโโโโโโฌโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโโโฌโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโ
โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ
โโโโโโโโโโโโโโโโโโผโโโโโผโโโโโโโผโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโผโโโโโโผโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโค
โ test_bad โ 2 โ fork โ 0 โ stopped โ 0 โ 0 โ 0% โ 0 B โ gombosg โ disabled โ
โ test_good โ 0 โ fork โ 0 โ stopped โ 0 โ 0 โ 0% โ 0 B โ gombosg โ disabled โ
โ test_overwrite โ 1 โ fork โ 0 โ stopped โ 0 โ 0 โ 0% โ 0 B โ gombosg โ disabled โ
โโโโโโโโโโโโโโโโโโดโโโโโดโโโโโโโดโโโโโโดโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโดโโโโโโดโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโ
===============================================================================
--- Daemon logs --------------------------------------------
/home/gombosg/.pm2/pm2.log last 20 lines:
PM2 | [2018-04-10 10:53:00] PM2 log: Starting execution sequence in -fork mode- for app name:test_good id:0
PM2 | [2018-04-10 10:53:00] PM2 log: App name:test_good id:0 online
PM2 | [2018-04-10 10:53:00] PM2 log: App [test_good] with id [0] and pid [3746], exited with code [0] via signal [SIGINT]
PM2 | [2018-04-10 10:53:00] PM2 log: Starting execution sequence in -fork mode- for app name:test_overwrite id:1
PM2 | [2018-04-10 10:53:00] PM2 log: App name:test_overwrite id:1 online
PM2 | [2018-04-10 10:53:00] PM2 log: App [test_overwrite] with id [1] and pid [3762], exited with code [0] via signal [SIGINT]
PM2 | [2018-04-10 10:53:00] PM2 log: Starting execution sequence in -fork mode- for app name:test_bad id:2
PM2 | [2018-04-10 10:53:00] PM2 log: App name:test_bad id:2 online
PM2 | [2018-04-10 10:53:00] PM2 log: App [test_bad] with id [2] and pid [3778], exited with code [0] via signal [SIGINT]
Just tried with this ecosystem.config.js:
````
module.exports = {
apps : [{
name : 'clustered_http',
script : './http.js',
instances : 'max',
output: '/dev/null',
node_args: '--inspect',
error: '/dev/null',
exec_mode : 'cluster',
env : {
PORT : 8002
}
}]
}
And with `pm2 logs` I notice that the inspector is properly enabled:
PM2 | Debugger listening on ws://127.0.0.1:9237/1a767699-938f-4db4-85c9-06fdd5222e2c
PM2 | For help see https://nodejs.org/en/docs/inspector
```
Thanks for looking into it! The bug report is not about node_args not working in the config file, but rather when you try to pass it from the CLI, it's ignored. My repro test above is still not working properly.