'use strict'; const Subscription = require('egg').Subscription; class Creeper extends Subscription { // 通过 schedule 属性来设置定时任务的执行间隔等配置 // 更改执行时间 static get schedule() { return { // cron: '0 6 30 * * ?', // 每天晚上23点执行任务 // // cron: '0 20 12 * * ?', // 每天晚上23点执行任务 interval: '2m', // 1分钟执行一次 type: 'worker', // 指定所有的 worker 都需要执行 }; } // subscribe 是真正定时任务执行时被运行的函数 async subscribe() { console.log('服务器集群节点查询'); await this.ctx.service.creeperxtsqnode.creeper();// qnodes } } module.exports = Creeper;