定时任务schedule里怎么获取ctx上下文对象
- Dominant language
- TypeScript
- Stars
- 264
- Forks
- 46
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 1
Description
### 在此输入你需要反馈的 Bug 具体信息(Bug in Detail):
'use strict';
import { IntervalParams, Schedule, ScheduleType } from '@eggjs/tegg/schedule';
@Schedule({
type: ScheduleType.WORKER,
scheduleData: {
interval: 600 * 10,
}
})
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
export class onlineSchedule {
async subscribe(ctx) {
console.log(ctx, 'SSEService')
}
}
是否可以支持subscribe里默认获取ctx类似于eggjs中task参数可以拿到ctx
'use strict';
const { nowTime } = require("../utils");
module.exports = app => {
return {
schedule: {
interval: '120s', // 2分钟间隔
// cron: '0 0 0 * * ?',
type: 'all', // 指定所有的 worker 都需要执行
},
async task(ctx) {
await ctx.service.global.judgeUserExpire()
console.log('2分钟执行一次,检查退出咨询情况' + nowTime())
},
};
};
### 可复现问题的仓库地址(Reproduction Repo)
暂无
### Node 版本号:
18.0.0
### TEgg 版本号:
3.12.0
### 相关插件名称与版本号:
3.12.0
### 操作平台与版本号:
3.12.0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.