简体   繁体   中英

Setup PM2 LogRotate using Ecosystem JS File

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM