p 2 log圧縮

2746 ワード

Description
PM 2 module to atomaticaally rotate logs of processes managed by PM 2.
Install
pm2 install pm2-logrotate
To install a specific version use the  @ スffix
pm2 install [email protected]
コンフィグ
  • max_size (Defaults to  10M):When a file size becompes higher than this value it will rotate it(its possible that the work check the file after it actually pass the limit)You can specife the unit the end:  10G、  10M、  10K
  • retain (Defaults to  30 file logs):This number is the number of rotated logs that are keep at any one time,it means that if You have retan=7 you will have at 7 rotated logs and your currentone.
  • compress (Defaults to  false):Enbale copression via gzip for all rotated logs
  • dateFormat (Defaults to  YYYY-MM-DD_HH-mm-ss):Format of the data used the name the file of logs
  • rotateModule (Defaults to  true):Rotate the log of pm 2's module like other apps
  • workerInterval (Defaults to  30 in secs):You can control at which interval the working the log s's size(minimum is)  1)
  • rotateInterval (Defaults to  0 0 * * * everyday at midnight:This cron is used to a force rotate when executed.We are using node-schedule トschedule cron,so all valid cron for node-schedule is valid cron for this option.Cron style:
  • TZ (Defaults to system time):This the standard tz database timezone used to offset the log file saved.For instance,a value of  Etc/GMT-1、with an horly logs、will save a file a hour  14 GMT with hour  13 GMT-1 in the log name.
  • *    *    *    *    *    *
    ┬    ┬    ┬    ┬    ┬    ┬
    │    │    │    │    │    |
    │    │    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
    │    │    │    │    └───── month (1 - 12)
    │    │    │    └────────── day of month (1 - 31)
    │    │    └─────────────── hour (0 - 23)
    │    └──────────────────── minute (0 - 59)
    └───────────────────────── second (0 - 59, OPTIONAL)
    
    How to set these values?
    After having installed the module you have to type:  pm2 set pm2-logrotate: e.g:
  • pm2 set pm2-logrotate:max_size 1K (1 KB)
  • pm2 set pm2-logrotate:compress true (comppress logs when rotated)
  • pm2 set pm2-logrotate:rotateInterval '*/1 * * * *' (force rotate everryminute)
  • https://www.npmjs.com/package/pm2-logrotate