Unitech / Unitech/pm2

pm2 restart ecosystem.config.js does not reload app details from ecosystem file

Open
#3,742 50 comments 34 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

I've seen slightly similar issues reported ( #3677, #3587 ) and I would like to add more detail

What's going wrong?

None of the restart | startOrRestart | startOrReload read updates from an ecosystem file.
I.e. changing the script path and running pm2 restart ecosystem.config.js --env production --update-env doesn't update the process process info

How could we reproduce this issue?

pm2 startOrReload ecosystem.config.js --env production --update-env

module.exports = {
  apps: [{
    name: "Internal API",
    script: "./internal_api/bundle.js",
    watch: true,
    kill_timeout: 10000,
    wait_ready: true,
    env_production: {
      NODE_ENV: "production",
      NODE_CONFIG_DIR: "./config"
    },
  }],
};

pm2 info 0

status            │ online                                          │
│ name              │ Internal API                                    │
│ restarts          │ 15                                              │
│ uptime            │ 75s                                             │
│ script path       │ /home/centos/internal_api/bundle.js             │
│ script args       │ N/A                                             │
│ error log path    │ /home/centos/.pm2/logs/Internal-API-error-0.log │
│ out log path      │ /home/centos/.pm2/logs/Internal-API-out-0.log   │
│ pid path          │ /home/centos/.pm2/pids/Internal-API-0.pid       │
│ interpreter       │ node                                            │
│ interpreter args  │ N/A                                             │
│ script id         │ 0                                               │
│ exec cwd          │ /home/centos                                    │
│ exec mode         │ fork_mode                                       │
│ node.js version   │ 8.11.3                                          │
│ watch & reload    │ ✔                                               │
│ unstable restarts │ 0                                               │
│ created at        │ N/A             

Update the ecosystem.config.js and change script path to script: "./internal-api/bundle.js" (hyphen instead of underscore), run pm2 startOrReload ecosystem.config.js --env production --update-env (same for reload, startOrRestart)

$ pm2 startOrReload ecosystem.config.js --env production --update-env
[PM2] Applying action reloadProcessId on app [Internal API](ids: 0)
[PM2] [Internal API](0) ✓

pm2 info 0 will show the old script path
│ script path │ /home/centos/internal_api/bundle.js

Edit:
Also, more of a question, but I would've expected that supplying an ecosystem file will enforce whatever apps are running?
I.e if I change the name of an app in the ecosystem file the it will be registered as a new process and the old one will keep running instead of killing everything except what's in the ecosystem.

Supporting information

$ pm2 report
[centos@ip-10-0-19-234 ~]$ pm2 report
===============================================================================
--- PM2 REPORT (Wed Jun 27 2018 10:03:50 GMT+0000 (UTC)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 2.10.4
node version         : 8.11.3
node path            : /usr/local/lib/npm/bin/pm2
argv                 : /usr/bin/node,/usr/local/lib/npm/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : centos
uid                  : 1000
gid                  : 1000
uptime               : 5min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 2.10.4
node version         : 8.11.3
node path            : /usr/local/lib/npm/bin/pm2
argv                 : /usr/bin/node,/usr/local/lib/npm/bin/pm2,report
argv0                : node
user                 : centos
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
cpus nb              : 1
freemem              : 389451776
totalmem             : 1038929920
home                 : /home/centos
===============================================================================
--- PM2 list -----------------------------------------------
┌──────────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬────────┬────────┬──────────┐
│ App name     │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem    │ user   │ watching │
├──────────────┼────┼──────┼─────┼────────┼─────────┼────────┼─────┼────────┼────────┼──────────┤
│ Internal API │ 0  │ fork │ 0   │ online │ 31      │ 58s    │ 0%  │ 0 B    │ centos │ enabled  │
└──────────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴────────┴────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
┌──────────────┬────┬──────┬─────┬────────┬─────────┬────────┬─────┬────────┬────────┬──────────┐
│ App name     │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem    │ user   │ watching │
├──────────────┼────┼──────┼─────┼────────┼─────────┼────────┼─────┼────────┼────────┼──────────┤
│ Internal API │ 0  │ fork │ 0   │ online │ 31      │ 58s    │ 0%  │ 0 B    │ centos │ enabled  │
└──────────────┴────┴──────┴─────┴────────┴─────────┴────────┴─────┴────────┴────────┴──────────┘

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 behavior with ecosystem.config.js using pm2 startOrReload, reload, and startOrRestart, then inspect the resulting pm2 info output. Confirm whether changed app details such as the script path are applied, and determine how renamed or removed apps should be handled when an ecosystem file is supplied.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.