rotate_by_hour.js 422 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const HourRotator = require('../lib/hour_rotator');
  3. module.exports = app => {
  4. const rotator = new HourRotator({ app });
  5. return {
  6. schedule: {
  7. type: 'worker', // only one worker run this task
  8. cron: '0 * * * *', // run every hour at 00
  9. disable: (app.config.logrotator.filesRotateByHour || []).length === 0,
  10. },
  11. async task() {
  12. await rotator.rotate();
  13. },
  14. };
  15. };