Unitech / Unitech/pm2

--max-restarts ignored by CLI

Open
#4,433 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What's going wrong?

I started a script with this exact command:

pm2 start ./start.js --name flickr2google --restart-delay 10000 --max-restarts 10

And later, the pm2 list command indicated me that the script restarted 121 times...

┌────────────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬───────────┬─────────┬──────────┐
│ App name       │ id │ version │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user    │ watching │
├────────────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼───────────┼─────────┼──────────┤
│ flickr2google  │ 8  │ 1.0.0   │ fork │ 29506 │ online │ 121     │ 5m     │ 0%  │ 77.5 MB   │ antoine │ disabled │

How could we reproduce this issue?

Create a script that stops after a few milliseconds and start it with the --max-restarts option.

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Sat Sep 28 2019 12:31:58 GMT+0200 (GMT+02:00)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.5.1
node version         : 10.16.3
node path            : /home/antoine/.npm-global/bin/pm2
argv                 : /usr/local/bin/node,/home/antoine/.npm-global/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : antoine
uid                  : 1000
gid                  : 1000
uptime               : 48709min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.5.1
node version         : 10.16.3
node path            : /home/antoine/.npm-global/bin/pm2
argv                 : /usr/local/bin/node,/home/antoine/.npm-global/bin/pm2,report
argv0                : node
user                 : antoine
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Atom(TM) CPU  C2350  @ 1.74GHz
cpus nb              : 2
freemem              : 217579520
totalmem             : 4119019520
home                 : /home/antoine
===============================================================================
--- PM2 list -----------------------------------------------
┌────────────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬────────────┬─────────┬──────────┐
│ App name       │ id │ version │ mode │ pid   │ status │ restart │ uptime │ cpu │ mem        │ user    │ watching │
├────────────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼────────────┼─────────┼──────────┤
│ flickr2google  │ 8  │ 1.0.0   │ fork │ 29506 │ online │ 121     │ 10m    │ 0%  │ 80.4 MB    │ antoine │ disabled │
│ form-to-ses    │ 3  │ 1.0.0   │ fork │ 4898  │ online │ 1       │ 33D    │ 0%  │ 53.9 MB    │ antoine │ disabled │
│ labrewlangerie │ 7  │ 1.0.0   │ fork │ 4778  │ online │ 2       │ 15D    │ 0%  │ 76.2 MB    │ antoine │ disabled │
│ lapagaiedaure  │ 4  │ 1.0.0   │ fork │ 4995  │ online │ 1       │ 33D    │ 0%  │ 59.0 MB    │ antoine │ disabled │
│ supercoloc     │ 2  │ N/A     │ fork │ 16490 │ online │ 71      │ 6h     │ 0%  │ 51.5 MB    │ antoine │ disabled │
│ tribeez        │ 0  │ N/A     │ fork │ 4718  │ online │ 1       │ 33D    │ 0%  │ 103.5 MB   │ antoine │ disabled │
│ tribeez-fcm    │ 1  │ N/A     │ fork │ 5260  │ online │ 1       │ 33D    │ 0%  │ 66.8 MB    │ antoine │ disabled │
└────────────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴────────────┴─────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/antoine/.pm2/pm2.log last 20 lines:
PM2        | 2019-09-28T08:56:00: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T08:56:00: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T08:56:06: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T08:56:16: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T08:56:16: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T08:56:25: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T08:56:35: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T08:56:36: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T08:56:42: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T08:56:52: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T08:56:52: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T08:57:03: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T08:57:13: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T08:57:13: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T09:00:14: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T09:00:24: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T09:00:24: PM2 log: App [flickr2google:8] online
PM2        | 2019-09-28T12:20:52: PM2 log: App [flickr2google:8] exited with code [1] via signal [SIGINT]
PM2        | 2019-09-28T12:21:02: PM2 log: App [flickr2google:8] starting in -fork mode-
PM2        | 2019-09-28T12:21:02: PM2 log: App [flickr2google:8] 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 a Node.js script that exits after a few milliseconds, using the shown pm2 start command and --max-restarts option. Compare the restart count in pm2 list with the configured limit, and use pm2 report and the daemon logs to trace the option through the CLI; done means restarts stop at the configured maximum.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.