Unitech / Unitech/pm2

pm2 start ecosystem does not start, it restarts!

Open
#5,508 2 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

pm2 should only start the apps that are new and not restart already started apps.

What's going wrong?

pm2 is restarting existing ecosystem, when you do a pm2 start ecosystem, where it should not.
I would expect that

pm2 startOrRestart would restart if it is already started.

How could we reproduce this issue?

  1. create an eco system file with 1 process
  2. run pm2 start ecosystem.js
  3. add an extra process to ecosystem.js
  4. run pm2 start ecosystem.js
  5. observe that the original proces was restarted

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Wed Dec 21 2022 14:16:19 GMT+0100 (Central European Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.1.2
node version         : 18.12.1
node path            : /tmp/fnm_multishells/6_1671492555830/bin/pm2
argv                 : /home/x-user-x/.fnm/node-versions/v18.12.1/installation/bin/node,/home/x-user-x/.fnm/node-versions/v18.12.1/installation/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : x-user-x
uid                  : 1000
gid                  : 1000
uptime               : 2267min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.1.2
node version         : 18.12.1
node path            : /tmp/fnm_multishells/289_1671625446299/bin/pm2
argv                 : /home/x-user-x/.fnm/node-versions/v18.12.1/installation/bin/node,/tmp/fnm_multishells/289_1671625446299/bin/pm2,report
argv0                : node
user                 : x-user-x
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-10700T CPU @ 2.00GHz
cpus nb              : 16
freemem              : 8051310592
totalmem             : 17051455488
home                 : /home/x-user-x
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name             │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ dws              │ default     │ N/A     │ fork    │ 527      │ 45m    │ 4    │ online    │ 2%       │ 152.9mb  │ sca… │ disabled │
│ 2   │ housekeeper      │ default     │ N/A     │ fork    │ 528      │ 45m    │ 4    │ online    │ 0%       │ 55.2mb   │ sca… │ disabled │
│ 3   │ promtail         │ default     │ N/A     │ fork    │ 542      │ 45m    │ 4    │ online    │ 0%       │ 39.9mb   │ sca… │ disabled │
└─────┴──────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Module
┌────┬──────────────────────────────┬───────────────┬──────────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module                       │ version       │ pid      │ status   │ ↺    │ cpu      │ mem      │ user     │
├────┼──────────────────────────────┼───────────────┼──────────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 0  │ pm2-logrotate                │ 2.7.0         │ 24       │ online   │ 0    │ 0%       │ 40.4mb   │ sca… │
└────┴──────────────────────────────┴───────────────┴──────────┴──────────┴──────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/x-user-x/.pm2/pm2.log last 20 lines:
PM2        | 2022-12-21T13:31:03: PM2 log: pid=490 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: pid=460 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: pid=490 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: pid=460 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: pid=490 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: pid=460 msg=failed to kill - retrying in 100ms
PM2        | 2022-12-21T13:31:03: PM2 log: App [dws:1] exited with code [0] via signal [SIGINT]
PM2        | 2022-12-21T13:31:03: PM2 log: App [housekeeper:2] exited with code [1] via signal [SIGINT]
PM2        | 2022-12-21T13:31:03: PM2 log: pid=490 msg=process killed
PM2        | 2022-12-21T13:31:03: PM2 log: App [dws:1] starting in -fork mode-
PM2        | 2022-12-21T13:31:03: PM2 log: App [dws:1] online
PM2        | 2022-12-21T13:31:03: PM2 log: pid=460 msg=process killed
PM2        | 2022-12-21T13:31:03: PM2 log: App [housekeeper:2] starting in -fork mode-
PM2        | 2022-12-21T13:31:03: PM2 log: App [housekeeper:2] online
PM2        | 2022-12-21T13:31:03: PM2 log: Process 3 in a stopped status, starting it
PM2        | 2022-12-21T13:31:03: PM2 log: Stopping app:promtail id:3
PM2        | 2022-12-21T13:31:03: PM2 log: App [promtail:3] exited with code [0] via signal [SIGINT]
PM2        | 2022-12-21T13:31:03: PM2 log: pid=468 msg=process killed
PM2        | 2022-12-21T13:31:03: PM2 log: App [promtail:3] starting in -fork mode-
PM2        | 2022-12-21T13:31:03: PM2 log: App [promtail:3] 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 behavior with an ecosystem.js file: start one process, add another, then run pm2 start ecosystem.js again. Compare this with pm2 startOrRestart; done means the existing process is not restarted while the newly added process starts.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.