Is it possible to see the restart log/history with PM2 app?
I saw my nodeJS app restarted a few times but no clue when.
I've checked pm2 documentation but no luck.
Is it possible to see the restart log/history with PM2 app?
I saw my nodeJS app restarted a few times but no clue when.
I've checked pm2 documentation but no luck.
PM2's own logs are streamed into the file ~/.pm2/pm2.log
Example commands for viewing:
cat ~/.pm2/pm2.log
tail -n 30 ~/.pm2/pm2.log
- last 30 lineswatch -n 1 tail -n 30 ~/.pm2/pm2.log
- last 30 lines, live-updated once per secondExample output:
2024-08-19T22:13:38: PM2 log: App [test-mem-limit:95] starting in -fork mode-
2024-08-19T22:13:38: PM2 log: App [test-mem-limit:95] online
2024-08-19T22:14:07: PM2 log: [PM2][WORKER] Process 95 restarted because it exceeds --max-memory-restart value (current_memory=4346691584 max_memory_limit=4294967296 [octets])
2024-08-19T22:14:07: PM2 log: Process 95 in a stopped status, starting it
2024-08-19T22:14:07: PM2 log: Stopping app:test-mem-limit id:95
2024-08-19T22:14:07: PM2 log: pid=3263791 msg=failed to kill - retrying in 100ms
2024-08-19T22:14:08: PM2 log: pid=3263791 msg=failed to kill - retrying in 100ms
2024-08-19T22:14:08: PM2 log: App [test-mem-limit:95] exited with code [0] via signal [SIGINT]
2024-08-19T22:14:08: PM2 log: pid=3263791 msg=process killed
2024-08-19T22:14:08: PM2 log: App [test-mem-limit:95] starting in -fork mode-
2024-08-19T22:14:08: PM2 log: App [test-mem-limit:95] online
cat ~/.pm2/pm2.log
–
Tramontane You can run the command: pm2 logs
for an output of all logs, relating to running apps and their error logs.
The first log file in the window will be the default PM2 ones, for this kind of information.
© 2022 - 2024 — McMap. All rights reserved.