@kne/fastify-task 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,6 +106,17 @@ module.exports = fp(async (fastify, options) => {
106
106
  };
107
107
 
108
108
  const runner = async () => {
109
+ const runningTaskCount = await models.task.count({
110
+ where: {
111
+ runnerType: 'system',
112
+ status: 'running'
113
+ }
114
+ });
115
+ const limit = options.limit - runningTaskCount;
116
+ if (limit <= 0) {
117
+ fastify.log.info(`当前运行中的系统任务数(${runningTaskCount})已达上限(${options.limit}),暂不执行新任务`);
118
+ return;
119
+ }
109
120
  const pendingTasks = await models.task.findAll({
110
121
  where: {
111
122
  runnerType: 'system',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-task",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "用于编排任务,追踪任务执行状态,结果",
5
5
  "main": "index.js",
6
6
  "scripts": {