Hi,
I'm trying to use pm2 inside a docker container (it works fine on the host machine), and I am getting this error:
:; docker logs test
/src/node_modules/pm2/lib/API.js:995
Common.printOut(conf.PREFIX_MSG + 'App [%s] launched (%d instances)', data[0].pm2_env.name, data.length);
^
TypeError: Cannot read property 'pm2_env' of undefined
at /src/node_modules/pm2/lib/API.js:995:86
at /src/node_modules/pm2-axon-rpc/lib/client.js:45:10
at Parser.<anonymous> (/src/node_modules/pm2-axon/lib/sockets/req.js:67:8)
I tried to look this up, and it seems that data is msg.args from the socket? I'm not sure what this is, or how to debug it further.
Is there anything I could do to figure out this issue further?
PM2/NodeJS version ?
Which Docker image are you using also?
Node version 6.10.1
pm2 version 2.1.4
It is a custom image that is built off of RHEL 7.3
I just updated to pm2 version 2.4.6, and I am getting the same error.
:; docker logs test
/src/node_modules/pm2/lib/API.js:1031
Common.printOut(conf.PREFIX_MSG + 'App [%s] launched (%d instances)', data[0].pm2_env.name, data.length);
^
TypeError: Cannot read property 'pm2_env' of undefined
at /src/node_modules/pm2/lib/API.js:1031:86
at /src/node_modules/pm2-axon-rpc/lib/client.js:45:10
at Parser.<anonymous> (/src/node_modules/pm2-axon/lib/sockets/req.js:67:8)
I think this might have to do with having a out_file and error_file property declared, though I haven't been able to completely isolate and reproduce that yet.
Same error - totally killed a deploy for me today.
Node 7.10.0
pm2 2.4.6
Going to try to revert back to diff version(s)..
Published under PM2 2.5
@tnguyen14 I think it may have to do with if the log file specified is accessible/writeable. That's what appeared to have solve the issue for me.
confirmed, it has been fixed. you can try the fix:
$ npm install Unitech/pm2#development -g
$ pm2 update
@andyfleming can you confirm what you did to fix this? I am using the latest docker container and it is still an issue.
Same here
To be honest, I can't remember what project I was working on where I ran into this, but I believe what solved the issue for me was reconfiguring the log settings (because the process didn't have permission to write logs where it was trying to).
If you use a processes.json config file to start your processes, try making sure you are sending errors/logs to stdout + stderr.
{
"apps" : [{
//...
"error_file": "/dev/stderr",
"out_file": "/dev/stdout",
//...
}]
}
Could you share the exact error you have ? @ivoribeiro @zachariahtimothy
Last version may have the same error but not the same lines (check here), it would be easier to pinpoint the problem with it
@andyfleming thanks I tried that with the same error.
@vmarchaud I am receiving the following:
/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:94
var pm_id = obj[0].pm2_env.pm_id;
^
TypeError: Cannot read property 'pm2_env' of undefined
at /usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:94:26
at /usr/local/lib/node_modules/pm2/lib/API.js:1009:21
at /usr/local/lib/node_modules/pm2/lib/API.js:1080:19
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:421:16
at replenish (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:941:25)
at iterateeCallback (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:931:17)
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:906:16
at /usr/local/lib/node_modules/pm2/lib/API.js:1046:16
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:3083:16
at replenish (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:946:17)
Hi @zachariahtimothy I had very similar error. Please make sure that you app.js file is in the expected location.
I came across the same error - turns out I had a typo in the args for pm2-docker.
Most helpful comment
I think this might have to do with having a
out_fileanderror_fileproperty declared, though I haven't been able to completely isolate and reproduce that yet.