Unitech / Unitech/pm2

"pm2 update" never ends when running it from a bash script

Open
#5,000 6 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

I'm running a script that install/updates many things including PM2, but when I try to update it. the script just freezes and I had to manually terminate it.

However, when I run the same commands directly on the terminal, it works fine.

How could we reproduce this issue?

Create a script with the following content:

npm install pm2@latest -g
pm2 update

And run it from the console

sudo bash that_script.sh

Having pm2 already installed, we update it and we end up having a different version on the local computer and on memory.
the pm2 update doesn't finish.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Fri Feb 26 2021 15:34:51 GMT-0300 (Uruguay Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.4
node version         : 12.20.1
node path            : not found
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
uptime               : 333min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.5
node version         : 12.21.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
cpus nb              : 6
freemem              : 683810816
totalmem             : 6222090240
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                  │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │  bacon_health_check    │ default     │ 1.0.0   │ fork    │ 53344    │ 4m     │ 0    │ online    │ 0%       │ 46.3mb   │ root     │ disabled │
└─────┴───────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2        | 2021-02-26T15:30:05: PM2 log: Stopping app:bacon_health_check id:0
PM2        | 2021-02-26T15:30:05: PM2 log: App [bacon_health_check:0] exited with code [0] via signal [SIGINT]
PM2        | 2021-02-26T15:30:05: PM2 log: pid=923 msg=process killed
PM2        | 2021-02-26T15:30:05: PM2 log: App [bacon_health_check:0] starting in -fork mode-
PM2        | 2021-02-26T15:30:06: PM2 log: App [bacon_health_check:0] online

Does anybody know why this is happening?

Thanks in advance!!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown npm install pm2@latest -g and pm2 update commands under sudo bash, then compare that behavior with running the commands directly in a terminal. Use the reported PM2 daemon and CLI version mismatch as the initial lead; done means pm2 update exits normally from the script.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.