Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm2 list -> user column shows undefined #3561

Closed
KaiSchwarz-cnic opened this issue Mar 22, 2018 · 16 comments
Closed

pm2 list -> user column shows undefined #3561

KaiSchwarz-cnic opened this issue Mar 22, 2018 · 16 comments

Comments

@KaiSchwarz-cnic
Copy link

KaiSchwarz-cnic commented Mar 22, 2018

pm2 list

image

user is shown as undefined. This is not application dependent, can also affect other apps that are shown correctly in the screen shot.


===============================================================================
--- PM2 REPORT (Thu Mar 22 2018 14:50:41 GMT+0000 (UTC)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 2.10.1
node version         : 6.13.1
node path            : /home/node/.nvm/versions/node/v6.13.1/bin/pm2
argv                 : /home/node/.nvm/versions/node/v6.13.1/bin/node,/home/node/.nvm/versions/node/v6.13.1/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : node
uid                  : 1000
gid                  : 1000
uptime               : 4601min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 2.10.1
node version         : 6.13.1
node path            : /home/node/.nvm/versions/node/v6.13.1/bin/pm2
argv                 : /home/node/.nvm/versions/node/v6.13.1/bin/node,/home/node/.nvm/versions/node/v6.13.1/bin/pm2,report
argv0                : node
user                 : node
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E3-1271 v3 @ 3.60GHz
cpus nb              : 8
freemem              : 811732992
totalmem             : 33694265344
home                 : /home/node
===============================================================================
--- PM2 list -----------------------------------------------
┌──────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬────────────┬───────────┬──────────┐
│ App name     │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem        │ user      │ watching │
├──────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼────────────┼───────────┼──────────┤
│ CP3[PRD]     │ 47 │ cluster │ 19589 │ online │ 15      │ 115m   │ 0%  │ 259.2 MB   │ node      │ disabled │
│ CP3[PRD]     │ 44 │ cluster │ 19441 │ online │ 15      │ 115m   │ 0%  │ 257.8 MB   │ node      │ disabled │
│ CP3[PRD]     │ 45 │ cluster │ 19521 │ online │ 15      │ 115m   │ 0%  │ 255.6 MB   │ node      │ disabled │
│ CP3[PRD]     │ 46 │ cluster │ 19527 │ online │ 15      │ 115m   │ 0%  │ 258.4 MB   │ node      │ disabled │
│ CP3[PRD]     │ 43 │ cluster │ 19435 │ online │ 15      │ 115m   │ 0%  │ 256.9 MB   │ node      │ disabled │
│ CP3[PRD]     │ 48 │ cluster │ 19595 │ online │ 15      │ 115m   │ 0%  │ 258.6 MB   │ node      │ disabled │
│ CP3[PRD]     │ 49 │ cluster │ 19675 │ online │ 15      │ 115m   │ 0%  │ 259.1 MB   │ node      │ disabled │
│ CP3[PRD]     │ 50 │ cluster │ 19681 │ online │ 15      │ 115m   │ 0%  │ 256.5 MB   │ node      │ disabled │
│ P80[PRD]     │ 51 │ cluster │ 23536 │ online │ 0       │ 47h    │ 0%  │ 35.8 MB    │ undefined │ disabled │
│ TLDINFO      │ 0  │ cluster │ 13903 │ online │ 2       │ 15h    │ 0%  │ 60.1 MB    │ node      │ disabled │
│ WEBHOOK[PRD] │ 52 │ cluster │ 723   │ online │ 5       │ 94m    │ 0%  │ 35.1 MB    │ node      │ disabled │
└──────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴────────────┴───────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/node/.pm2/pm2.log last 20 lines:
PM2        | [2018-03-22 12:55:13] PM2 log: App name:CP3[PRD] id:50 disconnected
PM2        | [2018-03-22 12:55:13] PM2 log: App [CP3[PRD]] with id [50] and pid [28352], exited with code [0] via signal [SIGINT]
PM2        | [2018-03-22 12:55:13] PM2 log: pid=28576 msg=process killed
PM2        | [2018-03-22 12:55:13] PM2 log: Starting execution sequence in -cluster mode- for app name:CP3[PRD] id:49
PM2        | [2018-03-22 12:55:13] PM2 log: pid=28352 msg=process killed
PM2        | [2018-03-22 12:55:13] PM2 log: Starting execution sequence in -cluster mode- for app name:CP3[PRD] id:50
PM2        | [2018-03-22 12:55:15] PM2 log: App name:CP3[PRD] id:49 online
PM2        | [2018-03-22 12:55:15] PM2 log: App name:CP3[PRD] id:50 online
PM2        | [2018-03-22 13:06:29] PM2 log: Stopping app:WEBHOOK[PRD] id:52
PM2        | [2018-03-22 13:06:29] PM2 log: App name:WEBHOOK[PRD] id:52 disconnected
PM2        | [2018-03-22 13:06:29] PM2 log: App [WEBHOOK[PRD]] with id [52] and pid [22831], exited with code [0] via signal [SIGINT]
PM2        | [2018-03-22 13:06:29] PM2 log: pid=22831 msg=process killed
PM2        | [2018-03-22 13:06:29] PM2 log: Starting execution sequence in -cluster mode- for app name:WEBHOOK[PRD] id:52
PM2        | [2018-03-22 13:06:32] PM2 log: App name:WEBHOOK[PRD] id:52 online
PM2        | [2018-03-22 13:16:04] PM2 log: Stopping app:WEBHOOK[PRD] id:52
PM2        | [2018-03-22 13:16:04] PM2 log: App name:WEBHOOK[PRD] id:52 disconnected
PM2        | [2018-03-22 13:16:04] PM2 log: App [WEBHOOK[PRD]] with id [52] and pid [27429], exited with code [0] via signal [SIGINT]
PM2        | [2018-03-22 13:16:04] PM2 log: pid=27429 msg=process killed
PM2        | [2018-03-22 13:16:04] PM2 log: Starting execution sequence in -cluster mode- for app name:WEBHOOK[PRD] id:52
PM2        | [2018-03-22 13:16:08] PM2 log: App name:WEBHOOK[PRD] id:52 online
@wallet77
Copy link
Contributor

Can't reproduce this issue.
We need more details to reproduce.

@KaiSchwarz-cnic
Copy link
Author

We have a webhook app which restarts the apps via child_process.exec.
A more detailed description can be found here: #3276

If you need further informations, please feel free to ask.

@wallet77
Copy link
Contributor

I think this is the problem.
We find user in pm2.env variable. But if you restart app with a hook we can't catch the user.

@KaiSchwarz-cnic
Copy link
Author

KaiSchwarz-cnic commented Mar 26, 2018

Doesn't make sense imo as this worked fine in the past.
We also provide the user in our pm2 configuration which we use to reload our apps.
So for sure pm2 should have access on this in the environment.

@kepi
Copy link

kepi commented Apr 23, 2018

We have same problem when starting PM2 from systemd unit. Correct user is set in systemd unit, application but in pm2 list it shows undefined.

using standard systemd script generated from pm

# /etc/systemd/system/pm2-web-ourapp.service
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=web-ourapp
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/local/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/web-ourapp/.pm2
PIDFile=/home/web-ourapp/.pm2/pm2.pid

ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill

@KoteKotlyarov
Copy link

KoteKotlyarov commented Apr 25, 2018

Long story short:

  • Run pm2 l to see everything is ok
  • Run npm install pm2@latest -g && pm2 update
  • Saw in logs messages about updating from 2.8.0 to 2.10.2 version
  • Saw in logs message about "All apps restored" and response of pm2 status with all apps in "stopping" status with "undefined" users
  • Run pm2 l again and saw no apps at all (Why ? It said all aps were restored)
  • Run pm2 resurrect and saw all apps are running with "undefined" users

All these actions are on screenshot.

Then I did:

  • Made a copy of /.pm2/dump.pm2 file
  • Deleted one application from pm2 monitor and redeployed it
  • Run pm2 l to validate that user is "centos"
  • Run pm2 save and compare 2 dumps
  • Found "username" property in last dump for redeployed app
  • Add "username": "centos", manually in all apps in current dump file
  • Run pm2 stop all && pm2 delete all
  • Run pm2 resurect and see all apps have "centos" user

Is it OK to do it ?

Env is Centos 7
capture

@KaiSchwarz-cnic
Copy link
Author

@wallet77 any update? the current flag could be changed at least, thanks

@wallet77
Copy link
Contributor

wallet77 commented May 2, 2018

Didn't have time to investigate.
I still need more information to find a way to reproduce, otherwise I can't really fix it.

@KaiSchwarz-cnic
Copy link
Author

@wallet77 KoteKotlyarov provided a step by step guide, isn't that enough?

@wallet77
Copy link
Contributor

wallet77 commented May 2, 2018

@Papakai Unfortunately no, on my computer I can't reproduce this issue.
Even if I type : npm install pm2@latest -g && pm2 update and if I follow all steps, my user is displayed as expected. I need to test on another environment I think.

@kepi
Copy link

kepi commented May 3, 2018

In our cases problem was fixed by upgrading PM2 and multiple restart/resurrects. Now everything is ok, unfortunately cannot pinpoint exact command which fixed it.

@KoteKotlyarov
Copy link

KoteKotlyarov commented May 3, 2018

@wallet77 I have mentioned analized dump files before and after doing those commands. The main different was in username property in app dump data.

In brief, to fix my issue was enough to add in old dump file username: centos for each app in dump file.
Looks like old version created dump without username property and new version tries to read that undefined username property. Its my opinion, didn't look into code.

It can be proofed by checking logic of creating and restoring dump file in 2 versions, for my case they were 2.8.0 and 2.10.2

@wallet77
Copy link
Contributor

@KoteKotlyarov indeed we change the dump file creating/restoring logic but it's not release. It's still on development branch.
Maybe another commit has an impact on this feature.

@ghost
Copy link

ghost commented Jun 1, 2018

i have the same issue. My .pm2/dump file has no "username" field. I just did an upgrade to the latest version (first did pm2 save), then pm2 update and this happened.

@Unitech
Copy link
Owner

Unitech commented Jun 3, 2018

fixed, will be landed on next release

@wallet77
Copy link
Contributor

wallet77 commented Jul 4, 2018

PM2 3.0.0 has been released:

$ npm install pm2@latest -g
$ pm2 update

Be aware of breaking changes, especially drop support for node 0.12.
Full list here : https://github.com/Unitech/pm2/blob/master/CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants