diff options
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/move-to-object-storage.ts | 17 | ||||
-rw-r--r-- | server/lib/job-queue/job-queue.ts | 11 |
2 files changed, 23 insertions, 5 deletions
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts index f480b32cd..49064052c 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts | |||
@@ -48,15 +48,24 @@ export async function processMoveToObjectStorage (job: Job) { | |||
48 | await doAfterLastJob({ video, previousVideoState: payload.previousVideoState, isNewVideo: payload.isNewVideo }) | 48 | await doAfterLastJob({ video, previousVideoState: payload.previousVideoState, isNewVideo: payload.isNewVideo }) |
49 | } | 49 | } |
50 | } catch (err) { | 50 | } catch (err) { |
51 | logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags }) | 51 | await onMoveToObjectStorageFailure(job, err) |
52 | |||
53 | await moveToFailedMoveToObjectStorageState(video) | ||
54 | await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove') | ||
55 | } | 52 | } |
56 | 53 | ||
57 | return payload.videoUUID | 54 | return payload.videoUUID |
58 | } | 55 | } |
59 | 56 | ||
57 | export async function onMoveToObjectStorageFailure (job: Job, err: any) { | ||
58 | const payload = job.data as MoveObjectStoragePayload | ||
59 | |||
60 | const video = await VideoModel.loadWithFiles(payload.videoUUID) | ||
61 | if (!video) return | ||
62 | |||
63 | logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTagsBase(video.uuid, video.url) }) | ||
64 | |||
65 | await moveToFailedMoveToObjectStorageState(video) | ||
66 | await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove') | ||
67 | } | ||
68 | |||
60 | // --------------------------------------------------------------------------- | 69 | // --------------------------------------------------------------------------- |
61 | 70 | ||
62 | async function moveWebTorrentFiles (video: MVideoWithAllFiles) { | 71 | async function moveWebTorrentFiles (video: MVideoWithAllFiles) { |
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index f339e9135..ce24763f1 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -33,7 +33,7 @@ import { refreshAPObject } from './handlers/activitypub-refresher' | |||
33 | import { processActorKeys } from './handlers/actor-keys' | 33 | import { processActorKeys } from './handlers/actor-keys' |
34 | import { processEmail } from './handlers/email' | 34 | import { processEmail } from './handlers/email' |
35 | import { processManageVideoTorrent } from './handlers/manage-video-torrent' | 35 | import { processManageVideoTorrent } from './handlers/manage-video-torrent' |
36 | import { processMoveToObjectStorage } from './handlers/move-to-object-storage' | 36 | import { onMoveToObjectStorageFailure, processMoveToObjectStorage } from './handlers/move-to-object-storage' |
37 | import { processVideoFileImport } from './handlers/video-file-import' | 37 | import { processVideoFileImport } from './handlers/video-file-import' |
38 | import { processVideoImport } from './handlers/video-import' | 38 | import { processVideoImport } from './handlers/video-import' |
39 | import { processVideoLiveEnding } from './handlers/video-live-ending' | 39 | import { processVideoLiveEnding } from './handlers/video-live-ending' |
@@ -88,6 +88,10 @@ const handlers: { [id in JobType]: (job: Job) => Promise<any> } = { | |||
88 | 'video-studio-edition': processVideoStudioEdition | 88 | 'video-studio-edition': processVideoStudioEdition |
89 | } | 89 | } |
90 | 90 | ||
91 | const errorHandlers: { [id in JobType]?: (job: Job, err: any) => Promise<any> } = { | ||
92 | 'move-to-object-storage': onMoveToObjectStorageFailure | ||
93 | } | ||
94 | |||
91 | const jobTypes: JobType[] = [ | 95 | const jobTypes: JobType[] = [ |
92 | 'activitypub-follow', | 96 | 'activitypub-follow', |
93 | 'activitypub-http-broadcast', | 97 | 'activitypub-http-broadcast', |
@@ -162,6 +166,11 @@ class JobQueue { | |||
162 | : 'error' | 166 | : 'error' |
163 | 167 | ||
164 | logger.log(logLevel, 'Cannot execute job %d in queue %s.', job.id, handlerName, { payload: job.data, err }) | 168 | logger.log(logLevel, 'Cannot execute job %d in queue %s.', job.id, handlerName, { payload: job.data, err }) |
169 | |||
170 | if (errorHandlers[job.name]) { | ||
171 | errorHandlers[job.name](job, err) | ||
172 | .catch(err => logger.error('Cannot run error handler for job failure %d in queue %s.', job.id, handlerName, { err })) | ||
173 | } | ||
165 | }) | 174 | }) |
166 | 175 | ||
167 | queue.on('error', err => { | 176 | queue.on('error', err => { |