pm2
pm2 copied to clipboard
Monit no logs
given this code
setInterval(() => {
console.log('testings..');
}, 2000);
and running this..
npx pm2 start tester.js
then running this..
pm2 monit
Related: #4257
@Unitech having the same issue. Providing the logs for the same
--- PM2 report ----------------------------------------------------------------
Date : Tue May 31 2022 17:10:15 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.2.0
node version : 16.15.0
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : ninad
uid : 1003
gid : 1004
uptime : 236min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.2.0
node version : 16.15.0
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : node
user : ninad
uid : 1003
gid : 1004
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Xeon(R) CPU @ 2.20GHz
cpus nb : 2
freemem : 7595384832
totalmem : 8340922368
home : /home/ninad
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼───────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ price_fill │ default │ N/A │ fork │ 16929 │ 2h │ 1 │ online │ 0% │ 34.1mb │ ninad │ disabled │
└─────┴───────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/ninad/.pm2/pm2.log last 20 lines:
PM2 | 2022-05-31T15:33:27: PM2 log: App [test:2] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T15:33:37: PM2 log: App [test:2] starting in -fork mode-
PM2 | 2022-05-31T15:33:37: PM2 log: App [test:2] online
PM2 | 2022-05-31T15:33:40: PM2 log: App [test:2] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T15:33:49: PM2 log: Stopping app:test id:2
PM2 | 2022-05-31T15:33:49: PM2 log: pid=19456 msg=process killed
PM2 | 2022-05-31T16:59:25: PM2 log: App [test:3] starting in -fork mode-
PM2 | 2022-05-31T16:59:25: PM2 log: App [test:3] online
PM2 | 2022-05-31T16:59:28: PM2 log: App [test:3] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T16:59:38: PM2 log: App [test:3] starting in -fork mode-
PM2 | 2022-05-31T16:59:38: PM2 log: App [test:3] online
PM2 | 2022-05-31T16:59:41: PM2 log: App [test:3] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T16:59:51: PM2 log: App [test:3] starting in -fork mode-
PM2 | 2022-05-31T16:59:51: PM2 log: App [test:3] online
PM2 | 2022-05-31T16:59:54: PM2 log: App [test:3] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T17:00:04: PM2 log: App [test:3] starting in -fork mode-
PM2 | 2022-05-31T17:00:05: PM2 log: App [test:3] online
PM2 | 2022-05-31T17:00:06: PM2 log: Stopping app:test id:3
PM2 | 2022-05-31T17:00:06: PM2 log: App [test:3] exited with code [0] via signal [SIGINT]
PM2 | 2022-05-31T17:00:06: PM2 log: pid=20122 msg=process killed
Running PM2+ and I'm getting no logs and no error reporting either. Right now, when running it on a local machine, I'm not getting the same issue. The logs and errors are visible as expected on the web dashboard.
I looked at the specifics page and the section on setup pm2 on a server
had something about exposing ports, which I've done.
Another interesting thing was that the pm2-%user%.service
was shown as inactive. Not sure if that's relevant.
systemctl status pm2-%user%
● pm2-%user%.service - PM2 process manager
Loaded: loaded (/etc/systemd/system/pm2-%user%.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: https://pm2.keymetrics.io/
If any additional logs or testing are required, please let me know.
@Unitech Adding to this issue : Running on the same machine(but admittedly with a different user), if I ran a script that started the python process instead of the python process directly, then I seem to get most of the logs it seems. Could it be that directly monitoring the stdout, or stderr is problematic but once that gets handed off to the script, it gets wrapped by the os and thus can use the standard monitoring approaches ?
Issue:
pm2 monit
shows logs for only those app which were started after pm2 monit
process.
It's the same for root user.
For those two everything works great:
Start: pm2 start index.js --watch --name mysql2-1 --time --log ../\"$(date +\"%Y_%m_%d_%I_%M_%p\").log\""
Logs: pm2 logs mysql2-1
Simple "fix":
Just launch pm2 monit
before your node application.
Versions:
node: v18.8.0
pm2: 5.2.0
os: Linux mx-master 5.10.0-17-amd64 #1 SMP Debian 5.10.136-1 (2022-08-13) x86_64 GNU/Linux
Just launch
pm2 monit
before your node application.
Tried that:
pm2 stop ...
pm2 monit
pm2 start ...
pm2 monit # it shows the logs
# but after exiting monit and entering for a second time...
pm2 monit # again, no logs :(
So, apparently only works for the first time you start monit, the second time fails to show the logs again.
Just launch
pm2 monit
before your node application.Tried that:
pm2 stop ... pm2 monit pm2 start ... pm2 monit # it shows the logs # but after exiting monit and entering for a second time... pm2 monit # again, no logs :(
So, apparently only works for the first time you start monit, the second time fails to show the logs again.
I've come up with a workaround, although it's a bit unconventional. You can utilize tmux
and execute pm2 monit
. After that, hit Control + B + D
to go back, and pm2 monit
will continue running in the background. Meanwhile, you can run all your other pm2 commands while the tmux
session is active. Finally, use only tmux a
command instead of pm2 monit
to see logs (tested)