Unitech / Unitech/pm2

startOrRestart fails when given a plain script

Open
#5,019 0 comments 1 reaction 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?

startOrRestart fails when given a plain script.

How could we reproduce this issue?

$ touch /tmp/dummy.js
$ pm2 startOrRestart /tmp/dummy.js
/usr/lib/node_modules/pm2/lib/API.js:948
    if (config.deploy)
               ^

TypeError: Cannot read property 'deploy' of undefined
    at API._startJson (/usr/lib/node_modules/pm2/lib/API.js:948:16)
    at Command.<anonymous> (/usr/lib/node_modules/pm2/lib/binaries/CLI.js:321:9)
    at Command.listener (/usr/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:315:20)
    at Command.parseArgs (/usr/lib/node_modules/pm2/node_modules/commander/index.js:651:12)
    at Command.parse (/usr/lib/node_modules/pm2/node_modules/commander/index.js:474:21)
    at beginCommandProcessing (/usr/lib/node_modules/pm2/lib/binaries/CLI.js:147:13)
    at /usr/lib/node_modules/pm2/lib/binaries/CLI.js:221:7
    at /usr/lib/node_modules/pm2/lib/API.js:182:16
    at /usr/lib/node_modules/pm2/lib/Client.js:54:16

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Tue Mar 16 2021 19:50:18 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.5
node version         : 14.16.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : app
uid                  : 1000
gid                  : 1000
uptime               : 157min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.5
node version         : 14.16.0
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : app
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
cpus nb              : 1
freemem              : 181379072
totalmem             : 1029009408
home                 : /home/app
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
└─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Current process list running is not in sync with saved list. App app app differs. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/app/.pm2/pm2.log last 20 lines:
PM2        | 2021-03-16T19:36:32: PM2 log: App [app:2] online
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] exited with code [1] via signal [SIGINT]
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] starting in -fork mode-
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] online
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] exited with code [1] via signal [SIGINT]
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] starting in -fork mode-
PM2        | 2021-03-16T19:36:33: PM2 log: App [app:2] online
PM2        | 2021-03-16T19:36:34: PM2 log: App [app:2] exited with code [1] via signal [SIGINT]
PM2        | 2021-03-16T19:36:34: PM2 log: App [app:2] starting in -fork mode-
PM2        | 2021-03-16T19:36:34: PM2 log: App [app:2] online
PM2        | 2021-03-16T19:36:35: PM2 log: App [app:2] exited with code [1] via signal [SIGINT]
PM2        | 2021-03-16T19:36:35: PM2 log: App [app:2] starting in -fork mode-
PM2        | 2021-03-16T19:36:35: PM2 log: App [app:2] online
PM2        | 2021-03-16T19:36:35: PM2 log: App [app:2] exited with code [1] via signal [SIGINT]
PM2        | 2021-03-16T19:36:35: PM2 log: Script /home/app/app/build/src/index.js had too many unstable restarts (16). Stopped. "errored"
PM2        | 2021-03-16T19:50:11: PM2 log: Stopping app:app id:1
PM2        | 2021-03-16T19:50:11: PM2 log: Stopping app:app id:2
PM2        | 2021-03-16T19:50:11: PM2 error: app=app id=2 does not have a pid
PM2        | 2021-03-16T19:50:11: PM2 log: App [app:1] exited with code [0] via signal [SIGINT]
PM2        | 2021-03-16T19:50:11: PM2 log: pid=365025 msg=process killed

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 with lib/API.js around line 948 and the CLI entry in lib/binaries/CLI.js around line 321. Reproduce the failure using the reported touch and pm2 startOrRestart commands, then trace how the plain script reaches _startJson. Done means the command no longer throws the reported TypeError for a plain script.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.