check.js 538 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Subscription = require('egg').Subscription;
  3. class CheckCheck extends Subscription {
  4. // 通过 schedule 属性来设置定时任务的执行间隔等配置
  5. // 更改执行时间
  6. static get schedule() {
  7. return {
  8. // cron: '0 0 0 * * *',
  9. interval: '30s',
  10. type: 'worker', // 指定所有的 worker 都需要执行
  11. };
  12. }
  13. // subscribe 是真正定时任务执行时被运行的函数
  14. async subscribe() {
  15. await this.ctx.service.intercept.check();
  16. }
  17. }
  18. module.exports = CheckCheck;