Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.4k stars 2.61k forks source link

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

Open sschneider-ihre-pvs opened 1 year ago

sschneider-ihre-pvs commented 1 year ago

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 : =============================================================================== --- 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: ```
hinogi commented 1 year ago

It doesn't matter if you use the plugin or not, I also tried a config file and it shows the same result. Logs work correctly in fork mode but in cluster mode the start up is logged in the log file and after that everything is piped to PM2 log.

hinogi commented 1 year ago

I also tried different names and even namespaces but nothing helps. pm2 log something will never show the app name or namespace for the clustered apps