eggjs / eggjs/egg

定时任务只执行一次,无法多次运行

Open
#4,642 3 comments 0 reactions 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Node Version:v14.16.0
Egg Version:v2.29.3
Plugin Name:
"egg-mongoose": "^3.3.1",
Plugin Version:
Platform: Mac os

在app/schedule下新建task.js文件,保存后只会执行一次,无法多次执行。

代码如下:
```js
const Subscription = require('egg').Subscription;

class Task extends Subscription {
static get schedule() {
return {
interval: '2s',
type: 'all',
env: ['local'],
disable: false,
};
}

async subscribe() {
this.ctx.logger.info('new Date():', new Date());
console.log(new Date());
}
}

module.exports = Task;

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.