task.js 637 B

123456789101112131415161718192021
  1. 'use strict';
  2. module.exports = {
  3. schedule: {
  4. cron: '0 0 9 * * *',
  5. // interval: '10s', // 时间间隔
  6. type: 'all', // 指定所有的 worker 都需要执行
  7. },
  8. async task(ctx) {
  9. const { redLine, checkDrive } = ctx.app.config;
  10. if (!checkDrive) return;
  11. if (!redLine) return;
  12. const diskList = await ctx.service.disk.diskInfo();
  13. const drive = diskList.find(f => f.mounted === checkDrive);
  14. if (!drive) return;
  15. const { capacity } = drive;
  16. const number = parseInt(capacity.replace('%', ''));
  17. if (number && number >= redLine) {
  18. await ctx.service.disk.sendWarningEmail();
  19. }
  20. },
  21. };