Setup PM2 LogRotate using Ecosystem JS File

1.8k Views Asked by At

I am currently using a PM2 ecosystem file ecosystem.config.js to start multiple Node.js apps using PM2.

module.exports = 
{
  "apps": [
    {
      "name": "foo",
      "script": "./foo.js",
    },
    {
      "name": "bar",
      "script": "./bar.js",
    },
    {
      "name": "baz",
      "script": "./baz.js",
    }
  ]
}

If we want to setup logrotate PM2 module to rotate my log files, instead of manually running the commands

pm2 set pm2-logrotate:max_size 1K 
pm2 set pm2-logrotate:compress true
pm2 set pm2-logrotate:rotateInterval '*/1 * * * *'

can the logrotate settings be configured using the ecosystem JS file?

1

There are 1 best solutions below

0
Sergio On BEST ANSWER

It is not possible. Based on pm2-logrotate author:

It's not possible apparently since pm2-logrotate is different than pm2, pm2 is not aware beforehand if pm2-lr is already installed or not.

Source: https://github.com/keymetrics/pm2-logrotate/issues/131