This issue only manifests in version 3.2.X, (only checked with node 10.X)
node-args not preserved on pm2 restart
// pm2dummy.js
let i = 0;
setInterval(() => {
console.log(i++);
if (i === 5) {
process.exit(1);
}
}, 1000);
pm2 start pm2dummy.js --node-args "--max-old-space-size=1000"
Do pm2 restart pm2dummy, then pm2 show pm2dummy
Should display
interpreter args | --max-old-space-size=1000
Instead display
interpreter args | N/A
===============================================================================
--- PM2 REPORT (Fri Nov 16 2018 09:38:50 GMT-0800 (Pacific Standard Time)) ----
===============================================================================
--- Daemon --------------------------------------------------------------------
pm2d version : 3.2.0
node version : 10.13.0
node path : /home/peter.parkour/.nvm/versions/node/v10.13.0/bin/pm2
argv : /home/peter.parkour/.nvm/versions/node/v10.13.0/bin/node,/home/peter.parkour/.nvm/versions/node/v10.13.0/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : peter.parkour
uid : 1000
gid : 1000
uptime : 32min
===============================================================================
--- CLI -----------------------------------------------------------------------
local pm2 : 3.2.0
node version : 10.13.0
node path : /home/peter.parkour/.nvm/versions/node/v10.13.0/bin/pm2
argv : /home/peter.parkour/.nvm/versions/node/v10.13.0/bin/node,/home/peter.parkour/.nvm/versions/node/v10.13.0/bin/pm2,report
argv0 : node
user : peter.parkour
uid : 1000
gid : 1000
===============================================================================
--- System info ---------------------------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
cpus nb : 8
freemem : 1038581760
totalmem : 16731594752
home : /home/peter.parkour
===============================================================================
--- PM2 list ------------------------------------------------------------------
ββββββββββββ¬βββββ¬ββββββββββ¬βββββββ¬ββββββββ¬βββββββββ¬ββββββββββ¬βββββββββ¬ββββββ¬ββββββββββββ¬βββββββ¬βββββββββββ
β App name β id β version β mode β pid β status β restart β uptime β cpu β mem β user β watching β
ββββββββββββΌβββββΌββββββββββΌβββββββΌββββββββΌβββββββββΌββββββββββΌβββββββββΌββββββΌββββββββββββΌβββββββΌβββββββββββ€
β pm2dummy β 0 β N/A β fork β 30206 β online β 91 β 1s β 0% β 34.8 MB β peter.parkour β disabled β
ββββββββββββ΄βββββ΄ββββββββββ΄βββββββ΄ββββββββ΄βββββββββ΄ββββββββββ΄βββββββββ΄ββββββ΄ββββββββββββ΄βββββββ΄βββββββββββ
===============================================================================
Yes, I have the following process.yml file, node_args and watch are not preserved anymore between process restarts.
apps:
- script : app.js
name : web
exec_mode : fork
# instances : 0
watch : true
ignore_watch :
- 'node_modules'
- 'logs'
node_args : '--inspect=5858'
env :
NODE_ENV: "development"
- script : scripts/cron-download-pixart.js
name : download
exec_mode : fork
watch : true
ignore_watch :
- 'node_modules'
- 'logs'
node_args : '--inspect=5859'
env :
NODE_ENV: "development"
Actually, watch is only lost when stopping and starting, not on restart.
I believe I've isolated the issue down to this commit
https://github.com/Unitech/pm2/commit/ccb35ef8ca437043f84f3651e0fc56534d37a143
npm install -g https://github.com/Unitech/pm2#ccb35ef
pm2 restart does not preserve the args
but the previous commit is fine
npm install -g https://github.com/Unitech/pm2#b4708e7
Both versions 3.1.3
@andy-ganchrow your PR solves the issue, I don't know if there's a better way to go about it though.
For one, the issue with watching persists, and by the way also for some reason also the execution mode always goes back to cluster for me, even if in the configuration it was fork. I think there's some bigger problem where the configuration is not loaded properly somehow or is overwritten by the the execution of pm2 itself.
Thanks @mcdado
I donβt know the pm2 code well at all so I was just doing console.log at different places in the infected commit until I saw the arguments disappear. My hope was the PR fixes this one issue without side effects. And Iβm assuming if it does the watch issue wonβt be hard to fix
Fixed in pm2 2.3.3:
npm install pm2@latest -g
pm2 update
https://github.com/Unitech/pm2/commit/213f48641beedd1a9b84f74a0f9d963a114eea14
Most helpful comment
Fixed in pm2 2.3.3:
https://github.com/Unitech/pm2/commit/213f48641beedd1a9b84f74a0f9d963a114eea14