pm2-logrotate icon indicating copy to clipboard operation
pm2-logrotate copied to clipboard

Log rotation isn't happening

Open rajashekhargundeti opened this issue 7 years ago • 19 comments

image

Hi,

I set the max size as 100M, it is not working.

It created a log of size 7.x GB.

rajashekhargundeti avatar Nov 23 '17 09:11 rajashekhargundeti

You might be missing the workerInterval

nitrocode avatar Dec 01 '17 03:12 nitrocode

image

It is showing workerInterval on complete details.

rajashekhargundeti avatar Dec 04 '17 09:12 rajashekhargundeti

What do you get when you run pm2 conf pm2-logrotate ?

nitrocode avatar Dec 05 '17 02:12 nitrocode

[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 .

rajashekhargundeti avatar Dec 05 '17 06:12 rajashekhargundeti

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?

nitrocode avatar Dec 05 '17 17:12 nitrocode

image

rajashekhargundeti avatar Dec 06 '17 06:12 rajashekhargundeti

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

nitrocode avatar Dec 06 '17 16:12 nitrocode

still doesn't work to me

AriesLian avatar Apr 13 '18 09:04 AriesLian

@AriesLian can you post on your github a minimal complete reproducible and verifiable example?

nitrocode avatar Apr 13 '18 19:04 nitrocode

i have same problem.

1 irteam cvbelli-crawler02 bash 0030-04-30 09-34-27 1 irteam cvbelli-sidebar01 pm2 logs bash 0030-04-30 09-34-17

logrotate is not working

insanehong avatar Apr 30 '18 00:04 insanehong

@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]

nitrocode avatar Apr 30 '18 04:04 nitrocode

pm2 install [email protected]

is what worked for me. v2.6.0 didn't show up as a module.

jquijino avatar Jun 08 '18 14:06 jquijino

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.

nitrocode avatar Jun 08 '18 20:06 nitrocode

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.

apoorv-mishra avatar Jul 01 '19 12:07 apoorv-mishra

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.

e-dot avatar Dec 05 '19 13:12 e-dot

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:

  1. Run all the processes which should be using logrotate (you can check list of them using pm2 list and make sure that they have ONLINE sign in status row)
  2. Also check that pm2-logrotate is also online
  3. 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 avatar Mar 13 '20 06:03 DelmorS

@DelmorS it did worked for me your solution, ty for the help @nitrocode do you have any idea why it's needed those steps?

Xunjin avatar Nov 20 '20 14:11 Xunjin

I believe it was this change in 2.7.0 that broke logrotate for multiple instances ~~in fork mode~~.

kmackinnon avatar Nov 03 '22 23:11 kmackinnon

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.

midnightcodr avatar Nov 12 '22 02:11 midnightcodr