Processes are not namespaced properly
Open
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?
If two ecosystem files have the same process names listed, but under different namespaces, PM2 will just override the ones added first with the ones added last.
How could we reproduce this issue?
Try starting these two ecosystem files with PM2:
production.json:
{
"apps": [
{
"name": "api",
"namespace": "production",
"script": "./server/server.js",
"cwd": "/home/production/src.production/api",
"watch": false,
"log_date_format": "YYYY-MM-DD HH:mm Z",
"error_file": "/var/log/api.production.err",
"out_file": "/var/log/api.production.out",
}
]
}
staging.json:
{
"apps": [
{
"name": "api",
"namespace": "staging",
"script": "./server/server.js",
"cwd": "/home/production/src.staging/api",
"watch": false,
"log_date_format": "YYYY-MM-DD HH:mm Z",
"error_file": "/var/log/api.staging.err",
"out_file": "/var/log/api.staging.out",
}
]
}
Supporting information
--- PM2 report ----------------------------------------------------------------
Date : Wed Aug 12 2020 18:50:51 GMT-0500 (Central Daylight Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 4.4.0
node version : 10.21.0
node path : /home/getsnoopy/.nvm/versions/node/v10.21.0/bin/pm2
argv : /home/getsnoopy/.nvm/versions/node/v10.21.0/bin/node,/home/getsnoopy/.nvm/versions/node/v10.21.0/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : getsnoopy
uid : 1000
gid : 1000
uptime : 13140min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 4.4.0
node version : 10.21.0
node path : /home/getsnoopy/.nvm/versions/node/v10.21.0/bin/pm2
argv : /home/getsnoopy/.nvm/versions/node/v10.21.0/bin/node,/home/getsnoopy/.nvm/versions/node/v10.21.0/bin/pm2,report
argv0 : node
user : getsnoopy
uid : 1000
gid : 1000
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
cpus nb : 4
freemem : 1699000320
totalmem : 16535830528
home : /home/getsnoopy
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼───────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ api.production │ production │ 1.0.0 │ cluster │ 30482 │ 5D │ 0 │ online │ 0.8% │ 102.4mb │ getsnoopy │ disabled │
│ 4 │ api.production │ production │ 1.0.0 │ cluster │ 30521 │ 5D │ 0 │ online │ 0.8% │ 105.8mb │ getsnoopy │ disabled │
│ 5 │ api.staging │ staging │ 1.0.0 │ fork │ 30544 │ 5D │ 0 │ online │ 0.8% │ 110.5mb │ getsnoopy │ disabled │
│ 1 │ cdn.production │ production │ 1.0.0 │ fork │ 30483 │ 5D │ 0 │ online │ 0.7% │ 85.8mb │ getsnoopy │ disabled │
│ 6 │ cdn.staging │ staging │ 1.0.0 │ fork │ 30571 │ 5D │ 0 │ online │ 0.7% │ 82.1mb │ getsnoopy │ disabled │
│ 2 │ sso.production │ production │ 0.9.0 │ fork │ 21742 │ 4D │ 11 │ online │ 0.7% │ 82.9mb │ getsnoopy │ disabled │
│ 7 │ sso.staging │ staging │ 0.9.0 │ fork │ 21684 │ 4D │ 11 │ online │ 0.8% │ 84.6mb │ getsnoopy │ disabled │
│ 3 │ web.production │ production │ 0.0.0 │ fork │ 8424 │ 3D │ 16 │ online │ 0.7% │ 55.1mb │ getsnoopy │ disabled │
│ 8 │ web.staging │ staging │ 0.0.0 │ fork │ 30651 │ 5D │ 0 │ online │ 0.8% │ 56.6mb │ getsnoopy │ disabled │
└─────┴───────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list running is not in sync with saved list. api cdn sso web api differs. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/getsnoopy/.pm2/pm2.log last 20 lines:
PM2 | 2020-08-09T15:53:21: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:21: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:21: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:53:21: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:53:22: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:23: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:23: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:53:23: PM2 log: App [web.production:3] online
PM2 | 2020-08-09T15:53:23: PM2 log: App [web.production:3] exited with code [1] via signal [SIGINT]
PM2 | 2020-08-09T15:53:23: PM2 log: Script /home/production/src.production/web/bin/server.js had too many unstable restarts (16). Stopped. "errored"
PM2 | 2020-08-09T15:54:46: PM2 log: App [web.production:3] starting in -fork mode-
PM2 | 2020-08-09T15:54:46: PM2 log: App [web.production:3] online
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the production.json and staging.json ecosystem examples, then compare the PM2 process list after both are started. Trace how process names and namespaces are represented in the process manager. Done means identically named api processes remain available under both production and staging namespaces without one replacing the other.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100