From 44a18657f6116ea3b556497e03b1aa11c069d074 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Fri, 30 Apr 2021 16:05:02 +0200 Subject: [PATCH] api: Allow reprocessing of stalled jobs --- api/src/models/Track.js | 2 +- api/src/queue.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api/src/models/Track.js b/api/src/models/Track.js index 1d68260..56797ae 100644 --- a/api/src/models/Track.js +++ b/api/src/models/Track.js @@ -202,7 +202,7 @@ class Track extends mongoose.Model { await this.save(); - return await queue.add( + await queue.add( 'processTrack', { trackId: this._id.toString(), diff --git a/api/src/queue.js b/api/src/queue.js index c7c1af7..9d81775 100644 --- a/api/src/queue.js +++ b/api/src/queue.js @@ -1,5 +1,12 @@ -const Bull = require('bull') +const Bull = require('bull'); -const config = require('./config') +const config = require('./config'); -module.exports = new Bull('processQueue', config.redisUrl) +module.exports = new Bull('processQueue', config.redisUrl, { + settings: { + // if the worker process is killed and restarted, e.g. due to reboot or + // upgrade, it is okay to wait for a timeout on the job and restart it + maxStalledCount: 3, + lockDuration: 120 * 1000, + }, +});