exec_mode: cluster, pm2 running npm, logs written to main process log
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, nodejs
- Domain
- cli, observability
Research direction
Start with the package.json script that launches app.js and the shown pm2-config.json, then reproduce with pm2 start npm -- start and cluster mode. Compare pm2 logs app, pm2 logs, and pm2 monit; done means cluster-launched npm application output is associated with app rather than the main process log.
Written by the indexing model from the issue text.
Description
What's going wrong?
Logs for my process are being sent to the output of pm2 logs and not pm2 logs app when running using cluster exec mode and using npm to launch the process.
Using pm2 to manage a process that is launched by npm (the reason for this is to use the "node" npm module that will allow the program to run with a specific version of the node binary)
How could we reproduce this issue?
If I use pm2 start npm -- start (with a package json that uses scripts: "node app.js"), this launches the process and logs are available for that process with pm2 monit or pm2 logs app. Great!
Using pm2 to launch the process with pm2 start pm2-config.json with values like below:
{
"name": "app",
"script": "npm",
"args": "start",
"cwd": "/home/nodejs/app",
"exec_mode": "cluster"
}
The application starts fine.
The application is running and pm2 shows it in pm2 list and pm2 monit.
LOGS are not available in pm2 monit or pm2 logs app.
If you use pm2 logs, you will see the app logs being written to the main process.
Supporting information
Related to closed ticket: https://github.com/Unitech/pm2/issues/3176
$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date : Fri May 22 2020 13:25:36 GMT+0100 (British Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 4.4.0
node version : 12.16.3
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : /usr/bin/node
user : nodejs
uid : 1001
gid : 1001
uptime : 16min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 4.4.0
node version : 12.16.3
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : /usr/bin/node
user : nodejs
uid : 1001
gid : 1001
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : AMD EPYC 7571
cpus nb : 2
freemem : 389259264
totalmem : 4077600768
home : /home/nodejs
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 4 │ app │ default │ N/A │ cluster │ 32509 │ 12m │ 1 │ online │ 0.1% │ 43.9mb │ nodejs │ disabled │
└─────┴──────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Module
┌────┬───────────────────────────────────────┬────────────────────┬───────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module │ version │ pid │ status │ ↺ │ cpu │ mem │ user │
├────┼───────────────────────────────────────┼────────────────────┼───────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 0 │ pm2-syslog │ 2.1.0 │ 29776 │ online │ 0 │ 0% │ 860.0kb │ nodejs │
└────┴───────────────────────────────────────┴────────────────────┴───────┴──────────┴──────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list running is not in sync with saved list. Type 'pm2 save' to synchronize or enable autosync via 'pm2 set pm2:autodump true'
===============================================================================
--- Daemon logs --------------------------------------------
/home/nodejs/.pm2/pm2.log last 20 lines:
PM2 | Running... v8.17.0
PM2 | Running... v8.17.0
PM2 | Running... v8.17.0
PM2 | Running... v8.17.0
PM2 | Running... v8.17.0
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
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.
More from Unitech/pm2
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Errors Open
Difficulty 4/5 3-5 days Newbie friendliness 28/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100