[英]why actionherojs Task does not start Automatically?
I want to run a task every 5 minutes using actionhero
task in node.js, the task that I defined in task folder is as below: 我想使用node.js中的
actionhero
任务每5分钟运行一个任务,我在任务文件夹中定义的任务如下:
'use strict';
exports.task = {
name: 'scheduleTask',
description: 'Convert Temp Data Into Portal',
frequency: 300000,
queue: 'syncPortal',
run: function (api, params, next) {
api.services.ErpToPortal
.syncInitializeFunctions({})
.then(() => {
return api.services.ErpToPortal
.syncPerson({})
})
.then(() => {
return api.services.ErpToPortal
.syncContractors({})
})
.then((res) => {
next(null, res);
})
.catch(function (err) {
api.log(err, 'error', err);
next(err);
});
}
};
My Problem here is that the task does not start automatically while starting actionhero
api server, am I missing anything here ? 我的问题是启动
actionhero
api服务器时任务不会自动启动,我在这里丢失了什么吗? as I understood from actionherojs documenation, after defining frequency for a task, by starting actionhero api server, the task should be started automatically. 从actionherojs文档中了解到,在为任务定义频率后,通过启动actionhero api服务器,应自动启动任务。
You will need to make sure that the config in config/tasks.js has an amount of running workers that is greater to 1 and that the scheduler is set to enabled: true. 您将需要确保config / tasks.js中的config的运行工作者数量大于1,并且调度程序设置为enabled:true。 By default this is not the case and the queue isn't available out-of-the-box.
默认情况下不是这种情况,并且队列不可用。
At actionhero you have to enqueue task to run first time. 在actionhero,您必须排队任务才能首次运行。
api.tasks.enqueue("taskname",params,'queue')
api.tasks.enqueue(“ taskname”,params,'queue')
After this if you want to repeat task use frequency definition at task 此后,如果要重复任务,请在任务上使用频率定义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.