keymetrics / pm2-logrotate

Automatically rotate all applications logs managed by PM2
1.25k stars 138 forks source link

TypeError ERR_INVALID_ARG_TYPE - Retain not working as well #98

Open cuteboi opened 6 years ago

cuteboi commented 6 years ago
0|pm2-logr | TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function
0|pm2-logr |     at _addListener (events.js:180:11)
0|pm2-logr |     at WriteStream.addListener (events.js:240:10)
0|pm2-logr |     at WriteStream.close (fs.js:2298:10)
0|pm2-logr |     at WriteStream.<anonymous> (/root/.pm2/modules/pm2-logrotate/node_modules/pm2-logrotate/app.js:138:17)
0|pm2-logr |     at WriteStream.emit (events.js:164:20)
0|pm2-logr |     at finishMaybe (_stream_writable.js:616:14)
0|pm2-logr |     at endWritable (_stream_writable.js:624:3)
0|pm2-logr |     at WriteStream.Writable.end (_stream_writable.js:575:5)
0|pm2-logr |     at ReadStream.onend (_stream_readable.js:598:10)
0|pm2-logr |     at Object.onceWrapper (events.js:254:19)

My pm2-logrotate logs are filled with this.

I'm also trying to control how many files are being retained, but it's ignoring the retain options:

== pm2-logrotate ==
┌────────────────┬─────────────────────┐
│ key            │ value               │
├────────────────┼─────────────────────┤
│ max_size       │ 50M                 │
│ retain         │ 1                   │
│ compress       │ false               │
│ dateFormat     │ YYYY-MM-DD_HH-mm-ss │
│ workerInterval │ 30                  │
│ rotateInterval │ 0 0 * * *           │
│ rotateModule   │ true                │
└────────────────┴─────────────────────┘

The retain is not being honored:

$ ls -lh | grep firewall-out | head | cut -b 28- 
  52M Mar 14 11:33 firewall-out.log
  51M Mar 14 08:18 firewall-out__2018-03-14_08-18-02.log
  51M Mar 14 08:18 firewall-out__2018-03-14_08-18-33.log
  51M Mar 14 08:19 firewall-out__2018-03-14_08-19-03.log
  51M Mar 14 08:19 firewall-out__2018-03-14_08-19-34.log
  51M Mar 14 08:20 firewall-out__2018-03-14_08-20-04.log
  51M Mar 14 08:20 firewall-out__2018-03-14_08-20-35.log
  51M Mar 14 08:21 firewall-out__2018-03-14_08-21-05.log
  51M Mar 14 08:21 firewall-out__2018-03-14_08-21-36.log
  51M Mar 14 08:22 firewall-out__2018-03-14_08-22-06.log

Node version

: node --version
v9.3.0
pm2 -V
2.9.1
 Module activated
┌───────────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┬──────┐
│ Module        │ version │ target PID │ status │ restart │ cpu │ memory      │ user │
├───────────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┼──────┤
│ pm2-logrotate │ 2.4.0   │ N/A        │ online │ 1533    │ 0%  │ 35.086 MB   │ root │
└───────────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┴──────┘

uname -a without hostname

FreeBSD Hostname 10.3-RELEASE-p19 FreeBSD 10.3-RELEASE-p19 #0 bbfdb9a1d(RELENG_2_3_4): Wed May  3 16:09:14 CDT 2017     root@ce23-amd64-builder:/builder/pfsense-234/tmp/obj/builder/pfsense-234/tmp/FreeBSD-src/sys/pfSense  amd64

Please advise.

MBeuttler commented 6 years ago

Same issue regulary observed on our current pi project. pm2-logrotate throws error and duplicates last log file ignoring the retain option.

JeanCarlosChavarriaHughes commented 6 years ago

Anyone knows a method of disabling or stopping the pm2-logrotate in the while ?

Cheese-Yu commented 6 years ago

Same issue. And pm2-logrotate duplicates last log file continue to wtrite.

MBeuttler commented 6 years ago

we've downgraded to 2.2.0 had no issues since.

pm2 install pm2-logrotate@2.2.0

awefeng commented 5 years ago

the same as you, log so large~ and can't retain version 2.4.0