Search code examples
node.jsbashpm2

Is there a way to figure out why a PM2 process restarted if the error log is empty?


$ pm2 --version
1.1.1

Started a shell script with pm2. It was gonna run for about 12 hours. Went back to check on it the next day and it was only halfway done. But I checked the logs and it looked like it had started over. Checked pm2 ls and yes, it had, 3 times. That seemed strange since all it was doing was sending some curls and had been doing fine for hours.

So I went to look at the error output:

[collumj@serverName ~]$ ll /opt/xyz/.pm2/logs | grep util-perf-testing

-rw-r--r-- 1 collumj alskdjflkas    0 Oct 12 21:27 util-perf-testing-error-54.log
-rw-r--r-- 1 collumj alskdjflkas    0 Oct 12 21:38 util-perf-testing-error-59.log
-rw-r--r-- 1 collumj alskdjflkas 6.8K Oct 12 21:36 util-perf-testing-out-54.log
-rw-r--r-- 1 collumj alskdjflkas  15K Oct 13 00:00 util-perf-testing-out-59__2016-10-13_00-00-00.log
-rw-r--r-- 1 collumj alskdjflkas 166K Oct 14 00:00 util-perf-testing-out-59__2016-10-14_00-00-00.log
-rw-r--r-- 1 collumj alskdjflkas 384K Oct 14 17:16 util-perf-testing-out-59.log

The two error logs are completely empty.

Does PM2 keep any sort of internal logs about restarts? The output of the shell script doesn't show any reason for it to restart and the error logs are empty. I'm looking at a complete mystery as to why this shell script would have restarted 3 times.


Solution

  • PM2 will store the reasons for resets in its log, which can be accessed like so: tail --lines 100 ~/.pm2/pm2.log.