1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| import { Provide, Inject, Schedule, CommonSchedule } from '@midwayjs/decorator';
| import { Context } from 'egg';
|
| @Provide()
| @Schedule({
| interval: 2333, // 2.333s 间隔
| type: 'worker', // 指定某一个 worker 执行
| //cron: '0 0 */3 * * *',
| })
| export class HelloCron implements CommonSchedule {
|
| @Inject()
| ctx: Context;
|
| // 定时执行的具体任务
| async exec() {
| this.ctx.logger.info(process.pid, 'hello');
| }
| }
|
|