Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.62k stars 2.63k forks source link

Tiny oversight for development builds and pm2 report due to semver check (temp fix included) #3695

Closed shikhir-arora closed 6 years ago

shikhir-arora commented 6 years ago

What's going wrong?

Just a small oversight perhaps, in the development branch currently at 3.0.0-alpha1, pm2 report will throw a defined error:

[PM2][ERROR] You need to update your Daemon, please type $ pm2 update.

This is obviously not what we want to do and it won't change the result.

This is due to the semvar check here at line 111.


How could we reproduce this issue?

npm install Unitech/pm2#development -g; pm2 update

Temporary Fix

I just fixed this quickly by changing the check on the above mentioned line to the following, which will parse out the build and is valid for any build that would be checked. The only case where it would return true where you may want it to return false is if someone used 2.6.0-alpha or any -prerelease of 2.6.0. That's very unlikely, and even if they were running that, it would fail anyways as it's still the same issue with the semver format.

Current snippet:


if (semver.satisfies(data, '>= 2.6.0'))

Changed to the following to fix:


if (semver.satisfies(semver.coerce(data), '>=2.6.0'))

You probably don't need this, but I will follow the guideline (I did get pm2 report working, as mentioned above).

If this is intentional, I apologize. I looked around and didn't see any other complaints about it on the issues tracker/Git blame, so I thought I'd bring it up since pm2 report seems like it'd have use on development builds for actual issues. πŸ™‚

Supporting information

===============================================================================
--- PM2 REPORT (Mon Jun 04 2018 22:02:48 GMT-0700 (PDT)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.0.0-alpha1
node version         : 10.3.0
node path            : /home/vlexar/.nvm/versions/node/v10.3.0/bin/pm2
argv                 : /home/vlexar/.nvm/versions/node/v10.3.0/bin/node,/home/vlexar/.nvm/versions/node/v10.3.0/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : vlexar
uid                  : 1000
gid                  : 1000
uptime               : 4min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.0.0-alpha1
node version         : 10.3.0
node path            : /home/vlexar/.nvm/versions/node/v10.3.0/bin/pm2
argv                 : /home/vlexar/.nvm/versions/node/v10.3.0/bin/node,/home/vlexar/.nvm/versions/node/v10.3.0/bin/pm2,report
argv0                : node
user                 : vlexar
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz
cpus nb              : 8
freemem              : 9438666752
totalmem             : 33366151168
home                 : /home/vlexar
===============================================================================
--- PM2 list -----------------------------------------------
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ App name       β”‚ id β”‚ mode β”‚ pid   β”‚ status β”‚ restart β”‚ uptime β”‚ cpu     β”‚ mem        β”‚ user   β”‚ watching β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ karmabot-2.0.0 β”‚ 1  β”‚ fork β”‚ 23749 β”‚ online β”‚ 0       β”‚ 4m     β”‚ 0.975%  β”‚ 156.0 MB   β”‚ vlexar β”‚ disabled β”‚
β”‚ lavalink.js    β”‚ 0  β”‚ fork β”‚ 23742 β”‚ online β”‚ 0       β”‚ 4m     β”‚ 0.0125% β”‚ 43.5 MB    β”‚ vlexar β”‚ disabled β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
===============================================================================
--- Daemon logs --------------------------------------------
/home/vlexar/.pm2/pm2.log last 20 lines:
PM2        | [2018-06-04 21:50:56] PM2 log: PM2 successfully stopped
PM2        | [2018-06-04 21:58:04] PM2 log: ===============================================================================
PM2        | [2018-06-04 21:58:04] PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | [2018-06-04 21:58:04] PM2 log: Time                 : Mon Jun 04 2018 21:58:04 GMT-0700 (PDT)
PM2        | [2018-06-04 21:58:04] PM2 log: PM2 version          : 3.0.0-alpha1
PM2        | [2018-06-04 21:58:04] PM2 log: Node.js version      : 10.3.0
PM2        | [2018-06-04 21:58:04] PM2 log: Current arch         : x64
PM2        | [2018-06-04 21:58:04] PM2 log: PM2 home             : /home/vlexar/.pm2
PM2        | [2018-06-04 21:58:04] PM2 log: PM2 PID file         : /home/vlexar/.pm2/pm2.pid
PM2        | [2018-06-04 21:58:04] PM2 log: RPC socket file      : /home/vlexar/.pm2/rpc.sock
PM2        | [2018-06-04 21:58:04] PM2 log: BUS socket file      : /home/vlexar/.pm2/pub.sock
PM2        | [2018-06-04 21:58:04] PM2 log: Application log path : /home/vlexar/.pm2/logs
PM2        | [2018-06-04 21:58:04] PM2 log: Process dump file    : /home/vlexar/.pm2/dump.pm2
PM2        | [2018-06-04 21:58:04] PM2 log: Concurrent actions   : 2
PM2        | [2018-06-04 21:58:04] PM2 log: SIGTERM timeout      : 1600
PM2        | [2018-06-04 21:58:04] PM2 log: ===============================================================================
PM2        | [2018-06-04 21:58:11] PM2 log: Starting execution sequence in -fork mode- for app name:lavalink.js id:0
PM2        | [2018-06-04 21:58:11] PM2 log: Starting execution sequence in -fork mode- for app name:karmabot-2.0.0 id:1
PM2        | [2018-06-04 21:58:11] PM2 log: App name:lavalink.js id:0 online
PM2        | [2018-06-04 21:58:11] PM2 log: App name:karmabot-2.0.0 id:1 online
wallet77 commented 6 years ago

Hi @shikhir-arora

Good catch. Indeed it's not critical because it happens only with version containing alpha. But I will fix it anyway.

shikhir-arora commented 6 years ago

No problem, I figured it was worth noting because development builds could be prone to more 'need' of the pm2 report feature.