pm2-logrotate
pm2-logrotate copied to clipboard
Log rotation isn't happening

Hi,
I set the max size as 100M, it is not working.
It created a log of size 7.x GB.
You might be missing the workerInterval

It is showing workerInterval on complete details.
What do you get when you run pm2 conf pm2-logrotate ?
[image: Inline image 1]
On Tue, Dec 5, 2017 at 7:39 AM, burritocode [email protected] wrote:
What do you get when you run pm2 conf pm2-logrotate ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pm2-hive/pm2-logrotate/issues/81#issuecomment-349172063, or mute the thread https://github.com/notifications/unsubscribe-auth/ALREpBt3aHvBcvsj2QKk4qxnk1Q8IU1Tks5s9KXggaJpZM4QofNT .
The attachment from your message didn't work. Can you copy and paste the output into this ticket and format it using the code tags?

You're missing workerInterval which will rotate the logs based on the file size.
Edit: I forgot the interval defaults to 30 seconds which explains the Process configuration screenshot and your specific pm2 defined settings. I'm not sure what's wrong here. Have you taken a look at the logs? Perhaps if you override the default to a different value it may work?
pm2 set pm2-logrotate:workerInterval 60
still doesn't work to me
@AriesLian can you post on your github a minimal complete reproducible and verifiable example?
i have same problem.

logrotate is not working
@insanehong it would be more helpful if you can provide a Minimal, Complete, and Verifiable example (click me)
You can also try downgrading to see if a recent change has affected it.
pm2 install [email protected]
That's bizarre but a separate issue https://github.com/keymetrics/pm2-logrotate/issues/103. You can install the latest version 2.6.0 by specifying it. See the issue for details.
This same issue seems to occur to us at one of our production servers. For my case, I think the rate at which server throws the logs at pm2-logrotate is higher than the rate at which it is able to rotate the logs. Even the default value of workerInterval doesn't make the rotation fast enough in our case. Hence, this results in a clog at <app-name>-stdout.log thereby gradually increasing its size. To address this issue, I don't think there's any backpressure handling mechanism in pm2-logrotate.
I had the same problem - log rotation didn't occur at all, until I read again the docs, and reinstalled properly the module with this command:
pm2 install pm2-logrotate
As mentioned in the doc, it's pm2 install and not npm install
And then log rotation started working.
Hope this helps,
Regards,
E.
I had the same issue with our PROD system - logrotate was working only for one of four node processes/applications, and not for all of them.
The only solution which helped was following:
- Run all the processes which should be using logrotate (you can check list of them using
pm2 listand make sure that they have ONLINE sign in status row) - Also check that pm2-logrotate is also online
- Run command
pm2 update- what will happen: it may change ids of all your running processes. For example, if before you had pm2-logrotate process id as 0, and your main apps as 1,2,3,4, it will be changed - your main app processese will receive ids 0,1,2,3, and pm2-logrotate will receive id 4. And after that everything will start working correctly.
@DelmorS it did worked for me your solution, ty for the help @nitrocode do you have any idea why it's needed those steps?
I believe it was this change in 2.7.0 that broke logrotate for multiple instances ~~in fork mode~~.
Happened to me with pm2-logrotate@2.7.0, downgrading to 2.6.0 fixed the problem. Thank you @kmackinnon
pm2 install [email protected]
p.s. the process I have is running in cluster mode.