123456789101112131415161718192021 |
- 'use strict';
- const Subscription = require('egg').Subscription;
- class CheckCheck extends Subscription {
- // 通过 schedule 属性来设置定时任务的执行间隔等配置
- // 更改执行时间
- static get schedule() {
- return {
- // cron: '0 0 0 * * *',
- interval: '30s',
- type: 'worker', // 指定所有的 worker 都需要执行
- };
- }
- // subscribe 是真正定时任务执行时被运行的函数
- async subscribe() {
- await this.ctx.service.intercept.check();
- }
- }
- module.exports = CheckCheck;
|