]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/job-queue.ts
Increase max stalled count in job queue
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / job-queue.ts
index 1b46180e8eea3cea5972e663b97b5e22897bb014..8ff0c169e092276543b2eaa5dfbaf6aa12906787 100644 (file)
@@ -64,7 +64,10 @@ class JobQueue {
     this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST
     const queueOptions = {
       prefix: this.jobRedisPrefix,
-      redis: Redis.getRedisClient()
+      redis: Redis.getRedisClient(),
+      settings: {
+        maxStalledCount: 10 // transcoding could be long, so jobs can often be interrupted by restarts
+      }
     }
 
     for (const handlerName of Object.keys(handlers)) {
@@ -83,11 +86,18 @@ class JobQueue {
     }
   }
 
+  terminate () {
+    for (const queueName of Object.keys(this.queues)) {
+      const queue = this.queues[queueName]
+      queue.close()
+    }
+  }
+
   createJob (obj: CreateJobArgument) {
     const queue = this.queues[obj.type]
     if (queue === undefined) {
       logger.error('Unknown queue %s: cannot create job.', obj.type)
-      return
+      throw Error('Unknown queue, cannot create job')
     }
 
     const jobArgs: Bull.JobOptions = {