You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been playing around with adopting the use of namespaces to get logs for some subgroup of a local dev environment, namely for webpack run via pm2. However when I tried it out alongside our existing usage of --lines 0 (as we spawn the logs likely before the apps start), I saw nothing.
How could we reproduce this issue?
Should be fairly trivial to reproduce.
Supporting information
I'm fairly certain I've tracked down the source of the issue, and I can put up a PR once I find the time.
The problem is that we check for lines === 0 before we do any logic for namespaces:
However, I don't think the answer is to move that logic lower so that we can utilize the computed namespaceList, since that's not even passed to Log.stream on L260. Instead, we can use the information we already have, and update this conditional:
I think this is preferable because if we utilized namespaceList we'd run afoul of another bug, namely that processes that're started later on don't get included in pm2 logs <namespace id> with the current implementation. But if we filtered the messages as they come in via the bus, we avoid bugs from computing and storing a list of processes that could become stale.
--- PM2 report ----------------------------------------------------------------
Date : Fri Aug 18 2023 17:12:09 GMT-0700 (Pacific Daylight Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.3.0
node version : 16.17.1
node path : not found
argv : /Users/bryan/src/coda/build/node-v16.17.1-darwin-x64/bin/node,/Users/bryan/src/coda/node_modules/.pnpm/pm2@5.3.0_patch_hash=pzool4mgrkkjf3a4ff3havxysq/node_modules/pm2/lib/Daemon.js
argv0 : node
user : bryan
uid : 503
gid : 20
uptime : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.3.0
node version : 16.17.1
node path : not found
argv : /Users/bryan/src/coda/build/node-v16.17.1-darwin-x64/bin/node,/Users/bryan/src/coda/node_modules/pm2/bin/pm2,report
argv0 : node
user : bryan
uid : 503
gid : 20
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : darwin
type : Darwin
cpus : Apple M1 Max
cpus nb : 10
freemem : 7747424256
totalmem : 68719476736
home : /Users/bryan
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
└────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/Users/bryan/.pm2/pm2.log last 20 lines:
PM2 | 2023-08-18T17:12:08: PM2 log: pid=7397 msg=process killed
PM2 | 2023-08-18T17:12:08: PM2 log: pid=7383 msg=process killed
PM2 | 2023-08-18T17:12:08: PM2 log: pid=7285 msg=process killed
PM2 | 2023-08-18T17:12:08: PM2 log: PM2 successfully stopped
PM2 | 2023-08-18T17:12:09: PM2 log: ===============================================================================
PM2 | 2023-08-18T17:12:09: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2 | 2023-08-18T17:12:09: PM2 log: Time : Fri Aug 18 2023 17:12:09 GMT-0700 (Pacific Daylight Time)
PM2 | 2023-08-18T17:12:09: PM2 log: PM2 version : 5.3.0
PM2 | 2023-08-18T17:12:09: PM2 log: Node.js version : 16.17.1
PM2 | 2023-08-18T17:12:09: PM2 log: Current arch : x64
PM2 | 2023-08-18T17:12:09: PM2 log: PM2 home : /Users/bryan/.pm2
PM2 | 2023-08-18T17:12:09: PM2 log: PM2 PID file : /Users/bryan/.pm2/pm2.pid
PM2 | 2023-08-18T17:12:09: PM2 log: RPC socket file : /Users/bryan/.pm2/rpc.sock
PM2 | 2023-08-18T17:12:09: PM2 log: BUS socket file : /Users/bryan/.pm2/pub.sock
PM2 | 2023-08-18T17:12:09: PM2 log: Application log path : /Users/bryan/.pm2/logs
PM2 | 2023-08-18T17:12:09: PM2 log: Worker Interval : 30000
PM2 | 2023-08-18T17:12:09: PM2 log: Process dump file : /Users/bryan/.pm2/dump.pm2
PM2 | 2023-08-18T17:12:09: PM2 log: Concurrent actions : 2
PM2 | 2023-08-18T17:12:09: PM2 log: SIGTERM timeout : 1600
PM2 | 2023-08-18T17:12:09: PM2 log: ===============================================================================
The text was updated successfully, but these errors were encountered:
What's going wrong?
I've been playing around with adopting the use of namespaces to get logs for some subgroup of a local dev environment, namely for webpack run via pm2. However when I tried it out alongside our existing usage of
--lines 0
(as we spawn the logs likely before the apps start), I saw nothing.How could we reproduce this issue?
Should be fairly trivial to reproduce.
Supporting information
I'm fairly certain I've tracked down the source of the issue, and I can put up a PR once I find the time.
The problem is that we check for
lines === 0
before we do any logic for namespaces:pm2/lib/API/LogManagement.js
Lines 171 to 172 in 311c532
However, I don't think the answer is to move that logic lower so that we can utilize the computed
namespaceList
, since that's not even passed toLog.stream
on L260. Instead, we can use the information we already have, and update this conditional:pm2/lib/API/Log.js
Lines 101 to 104 in 311c532
I.e. we'd update it to be something like
I think this is preferable because if we utilized
namespaceList
we'd run afoul of another bug, namely that processes that're started later on don't get included inpm2 logs <namespace id>
with the current implementation. But if we filtered the messages as they come in via the bus, we avoid bugs from computing and storing a list of processes that could become stale.The text was updated successfully, but these errors were encountered: