Node.js Kue 如何重启失败的作业 [英] Node.js Kue how to restart failed jobs

查看:22
本文介绍了Node.js Kue 如何重启失败的作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 node.js 应用程序中使用 kue 处理延迟作业.

我有一些问题要弄清楚如何使用 kue 的 API 重新启动作业,而不必使用 redis 命令手动将作业 ID 从失败作业列表移动到非活动作业列表.

这可以使用 kue 吗?

我不想设置固定的重试次数 - 我只想重试特定的作业.

也欢迎提供维护良好的 kue 替代方案的建议.

解决方案

我不知道这是否有效,但您可以尝试将作业的状态重置为活动状态,然后再次保存作业:

job.on('失败', function() {job.state('inactive').save();

将状态设置为非活动将正确地重新排队任务.

I am using kue for delayed jobs in my node.js application.

I have some problems to figure out how I can restart a job using the API of kue without having to move the id of a job manually from the the list of failed jobs to the list of inactive jobs using redis commands.

Is this possible using kue?

I don't want to set a fixed number of retry attempts - I just want to retry specific jobs.

Suggestions for a well maintained alternative to kue are also welcome.

解决方案

i dont know if this is working but you could try to reset the state of the job to active, and save the job again:

job.on('failed', function() {
  job.state('inactive').save();

Edit: setting state to inactive will correctly re-enqueue the task.

这篇关于Node.js Kue 如何重启失败的作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆