Unitech / Unitech/pm2

pm2 module will be uninstalled twice when use the command of uninstall all

Open
#4,983 0 comments 0 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?

When I write a module with such package.json

{
  "name": "myapp",
  "version": "0.8.0",
  "description": "PM2 Module running myapp",
  "apps": [
    {
      "name": "app1",
      "script": "app1.js",
      "restart_delay": 100,
      "max_restarts": 0,
      "error_file": "/app/log/app1-error.log",
      "out_file": "/app/log/app1-out.log"
    },
    {
      "name": "app2",
      "script": "app2.js",
      "restart_delay": 100,
      "max_restarts": 0,
      "time": true,
      "error_file": "/app/log/app2-error.log",
      "out_file": "/app/log/app2-out.log"
    }
  ]
}

When update its code to re-install it, I need uninstall it first. So I use pm2 uninstall all command. But it will uninstall myapp twice.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Wed Feb 03 2021 19:01:33 GMT+0800 (China Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.4
node version         : 12.20.1
node path            : /root/.tnvm/versions/alinode/v5.18.1/bin/pm2
argv                 : /root/.tnvm/versions/alinode/v5.18.1/bin/node,/root/.tnvm/versions/alinode/v5.18.1/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
uptime               : 49min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.4
node version         : 12.20.1
node path            : /root/.tnvm/versions/alinode/v5.18.1/bin/pm2
argv                 : /root/.tnvm/versions/alinode/v5.18.1/bin/node,/root/.tnvm/versions/alinode/v5.18.1/bin/pm2,report
argv0                : node
user                 : root
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel Xeon Processor (Cascadelake)
cpus nb              : 16
freemem              : 3800711168
totalmem             : 33732665344
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                     │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
└─────┴──────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Modules
┌────┬───────────────────────────────────────┬────────────────────┬───────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module                                │ version            │ pid   │ status   │ ↺    │ cpu      │ mem      │ user     │
├────┼───────────────────────────────────────┼────────────────────┼───────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 4  │ myapp:app1                            │ 0.8.0              │ 7245  │ online   │ 0    │ 0.5%     │ 32.5mb   │ root     │
│ 5  │ myapp:app2                            │ 0.8.0              │ 7251  │ online   │ 0    │ 0%       │ 28.8mb   │ root     │
│ 2  │ xmn                                   │ N/A                │ 2990  │ online   │ 0    │ 0%       │ 1.2mb    │ root     │
│ 3  │ mytoken:monitor                       │ 0.0.2              │ 2992  │ online   │ 0    │ 0.9%     │ 24.5mb   │ root     │
└────┴───────────────────────────────────────┴────────────────────┴───────┴──────────┴──────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/root/.pm2/pm2.log last 20 lines:
PM2        | 2021-02-03T18:12:00: PM2 log: ===============================================================================
PM2        | 2021-02-03T18:12:00: PM2 log: App [myapp:app1:0] starting in -fork mode-
PM2        | 2021-02-03T18:12:00: PM2 log: App [myapp:app2:1] starting in -fork mode-
PM2        | 2021-02-03T18:12:00: PM2 log: App [myapp:app1:0] online
PM2        | 2021-02-03T18:12:00: PM2 log: App [myapp:app2:1] online
PM2        | 2021-02-03T18:12:00: PM2 log: App [xmn:2] starting in -fork mode-
PM2        | 2021-02-03T18:12:00: PM2 log: App [xmn:2] online
PM2        | 2021-02-03T18:12:00: PM2 log: App [mytoken:monitor:3] starting in -fork mode-
PM2        | 2021-02-03T18:12:00: PM2 log: App [mytoken:monitor:3] online
PM2        | 2021-02-03T18:31:01: PM2 log: Stopping app:myapp:app1 id:0
PM2        | 2021-02-03T18:31:01: PM2 log: pid=2969 msg=failed to kill - retrying in 100ms
PM2        | 2021-02-03T18:31:01: PM2 log: App [myapp:app1:0] exited with code [0] via signal [SIGINT]
PM2        | 2021-02-03T18:31:01: PM2 log: pid=2969 msg=process killed
PM2        | 2021-02-03T18:31:03: PM2 log: Stopping app:myapp:app2 id:1
PM2        | 2021-02-03T18:31:03: PM2 log: App [myapp:app2:1] exited with code [0] via signal [SIGINT]
PM2        | 2021-02-03T18:31:03: PM2 log: pid=2975 msg=process killed
PM2        | 2021-02-03T18:32:18: PM2 log: App [myapp:app1:4] starting in -fork mode-
PM2        | 2021-02-03T18:32:18: PM2 log: App [myapp:app2:5] starting in -fork mode-
PM2        | 2021-02-03T18:32:18: PM2 log: App [myapp:app1:4] online
PM2        | 2021-02-03T18:32:18: PM2 log: App [myapp:app2:5] online

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

Reproduce the issue with the shown package.json and the pm2 uninstall all command, then trace the command's module-uninstall path. Done means each module is uninstalled once and the command completes without attempting to remove the same module twice.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.