Unitech / Unitech/pm2

🐛 BUG: Logs get aggregated in PM2.log in cluster mode

Open
#5,633 2 comments 0 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

What's going wrong?

So I have multiple apps that by default have their own log files in the default folder. They are used in fork mode as they should.
Now, when I turn them into cluster mode. They start in their previous log files but then all stdout from the running apps only land in the main pm2.log which is very confusing. So the daemon takes it all.

How could we reproduce this issue?

  1. https://jonascodeblog.vercel.app/blog/nx-pm2-plugin follow those steps
  2. then add "instances": 1 to the pm2 target config options.

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Thu Jul 06 2023 18:46:52 GMT+0200 (Mitteleuropäische Sommerzeit)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.3.0
node version         : 18.14.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,$HOME\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0                : node
user                 : undefined
uid                  : N/A
gid                  : N/A
uptime               : 25min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.3.0
node version         : 18.14.0
node path            : not found
argv                 : C:\Program Files\nodejs\node.exe,$HOME\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0                : C:\Program Files\nodejs\node.exe
user                 : <truncated>
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : win32
type                 : Windows_NT
cpus                 : AMD Ryzen 7 PRO 5875U with Radeon Graphics
cpus nb              : 16
freemem              : 28255612928
totalmem             : 50246049792
home                 : $HOME
===============================================================================
--- PM2 list -----------------------------------------------
id name namespace version mode pid uptime status cpu mem user watching
0 app0 default 15.6.3 cluster 11620 22m 0 online 0.3% 98.5mb truncated disabled
2 app2 default 15.6.3 cluster 15020 22m 0 online 0.3% 97.7mb truncated disabled
5 app5 default 15.6.3 cluster 23764 10m 5 online 0% 99.4mb truncated disabled
6 app6 default 15.6.3 cluster 24724 11m 0 online 0% 99.0mb truncated disabled
4 app4 default 15.6.3 cluster 11972 22m 0 online 0% 97.6mb truncated disabled
===============================================================================
--- Daemon logs --------------------------------------------
$HOME\.pm2\pm2.log last 20 lines:
<truncated>

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

Follow the linked reproduction steps and add "instances": 1 to the PM2 target configuration, then inspect how cluster-mode stdout is routed versus fork-mode logs. Use the supplied pm2 report output to confirm the behavior; done means each app's stdout remains in its own log file instead of being aggregated in the main pm2.log.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.