Skip to content

pm2 logs with a namespace doesn't work if run before relevant pm2 start #5788

@bawjensen

Description

@bawjensen

What's going wrong?

If you try to start the logging before you've started the processes (perhaps because you want to make sure you don't miss any logs), then it breaks when provided with a namespace.

How could we reproduce this issue?

Should be simple enough to reproduce, e.g. pm2 logs my-namespace and pm2 start index.js --namespace my-namespace.

I do a better job of demonstrating the repro steps in #5789 with the e2e test.

Supporting information

# Run the following commands
$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Mon Mar 18 2024 15:29:19 GMT-0700 (Pacific Daylight Time)
===============================================================================
--- Daemon --------------------------------------------------------------------
pm2d version         : 5.3.1
node version         : 20.8.0
node path            : /Users/bryan/src/coda/build/node/bin/node
argv                 : /Users/bryan/src/coda/build/node-v20.8.0-darwin-arm64/bin/node,/Users/bryan/sandbox/pm2/lib/Daemon.js
argv0                : node
user                 : bryan
uid                  : 503
gid                  : 20
uptime               : 13min
===============================================================================
--- CLI -----------------------------------------------------------------------
local pm2            : 5.3.1
node version         : 20.8.0
node path            : not found
argv                 : /Users/bryan/src/coda/build/node-v20.8.0-darwin-arm64/bin/node,/Users/bryan/src/coda/node_modules/pm2/bin/pm2,report
argv0                : node
user                 : bryan
uid                  : 503
gid                  : 20
===============================================================================
--- System info ---------------------------------------------------------------
arch                 : arm64
platform             : darwin
type                 : Darwin
cpus                 : Apple M1 Max
cpus nb              : 10
freemem              : 7786971136
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        | 2024-03-18T15:09:01: PM2 log: PM2 home             : /Users/bryan/.pm2
PM2        | 2024-03-18T15:09:01: PM2 log: PM2 PID file         : /Users/bryan/.pm2/pm2.pid
PM2        | 2024-03-18T15:09:01: PM2 log: RPC socket file      : /Users/bryan/.pm2/rpc.sock
PM2        | 2024-03-18T15:09:01: PM2 log: BUS socket file      : /Users/bryan/.pm2/pub.sock
PM2        | 2024-03-18T15:09:01: PM2 log: Application log path : /Users/bryan/.pm2/logs
PM2        | 2024-03-18T15:09:01: PM2 log: Worker Interval      : 30000
PM2        | 2024-03-18T15:09:01: PM2 log: Process dump file    : /Users/bryan/.pm2/dump.pm2
PM2        | 2024-03-18T15:09:01: PM2 log: Concurrent actions   : 2
PM2        | 2024-03-18T15:09:01: PM2 log: SIGTERM timeout      : 1600
PM2        | 2024-03-18T15:09:01: PM2 log: ===============================================================================
PM2        | 2024-03-18T15:09:38: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:10:05: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:10:17: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:10:40: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:11:21: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:12:21: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:13:19: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:13:51: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:14:25: PM2 log: PM2 successfully stopped
PM2        | 2024-03-18T15:16:00: PM2 log: PM2 successfully stopped

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions