123456789101112131415161718192021 |
- 'use strict';
- module.exports = {
- schedule: {
- cron: '0 0 9 * * *',
- // interval: '10s', // 时间间隔
- type: 'all', // 指定所有的 worker 都需要执行
- },
- async task(ctx) {
- const { redLine, checkDrive } = ctx.app.config;
- if (!checkDrive) return;
- if (!redLine) return;
- const diskList = await ctx.service.disk.diskInfo();
- const drive = diskList.find(f => f.mounted === checkDrive);
- if (!drive) return;
- const { capacity } = drive;
- const number = parseInt(capacity.replace('%', ''));
- if (number && number >= redLine) {
- await ctx.service.disk.sendWarningEmail();
- }
- },
- };
|