diff options
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/move-to-object-storage.ts | 17 |
1 files changed, 13 insertions, 4 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 9e39322a8..69b441176 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Job } from 'bull' | 1 | import { Job } from 'bull' |
2 | import { remove } from 'fs-extra' | 2 | import { remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
5 | import { updateTorrentMetadata } from '@server/helpers/webtorrent' | 5 | import { updateTorrentMetadata } from '@server/helpers/webtorrent' |
6 | import { CONFIG } from '@server/initializers/config' | 6 | import { CONFIG } from '@server/initializers/config' |
7 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' | 7 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' |
@@ -13,6 +13,8 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info' | |||
13 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' | 13 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' |
14 | import { MoveObjectStoragePayload, VideoStorage } from '@shared/models' | 14 | import { MoveObjectStoragePayload, VideoStorage } from '@shared/models' |
15 | 15 | ||
16 | const lTagsBase = loggerTagsFactory('move-object-storage') | ||
17 | |||
16 | export async function processMoveToObjectStorage (job: Job) { | 18 | export async function processMoveToObjectStorage (job: Job) { |
17 | const payload = job.data as MoveObjectStoragePayload | 19 | const payload = job.data as MoveObjectStoragePayload |
18 | logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) | 20 | logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) |
@@ -20,26 +22,33 @@ export async function processMoveToObjectStorage (job: Job) { | |||
20 | const video = await VideoModel.loadWithFiles(payload.videoUUID) | 22 | const video = await VideoModel.loadWithFiles(payload.videoUUID) |
21 | // No video, maybe deleted? | 23 | // No video, maybe deleted? |
22 | if (!video) { | 24 | if (!video) { |
23 | logger.info('Can\'t process job %d, video does not exist.', job.id) | 25 | logger.info('Can\'t process job %d, video does not exist.', job.id, lTagsBase(payload.videoUUID)) |
24 | return undefined | 26 | return undefined |
25 | } | 27 | } |
26 | 28 | ||
29 | const lTags = lTagsBase(video.uuid, video.url) | ||
30 | |||
27 | try { | 31 | try { |
28 | if (video.VideoFiles) { | 32 | if (video.VideoFiles) { |
33 | logger.debug('Moving %d webtorrent files for video %s.', video.VideoFiles.length, video.uuid, lTags) | ||
34 | |||
29 | await moveWebTorrentFiles(video) | 35 | await moveWebTorrentFiles(video) |
30 | } | 36 | } |
31 | 37 | ||
32 | if (video.VideoStreamingPlaylists) { | 38 | if (video.VideoStreamingPlaylists) { |
39 | logger.debug('Moving HLS playlist of %s.', video.uuid) | ||
40 | |||
33 | await moveHLSFiles(video) | 41 | await moveHLSFiles(video) |
34 | } | 42 | } |
35 | 43 | ||
36 | const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove') | 44 | const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove') |
37 | if (pendingMove === 0) { | 45 | if (pendingMove === 0) { |
38 | logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id) | 46 | logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id, lTags) |
47 | |||
39 | await doAfterLastJob(video, payload.isNewVideo) | 48 | await doAfterLastJob(video, payload.isNewVideo) |
40 | } | 49 | } |
41 | } catch (err) { | 50 | } catch (err) { |
42 | logger.error('Cannot move video %s to object storage.', video.url, { err }) | 51 | logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags }) |
43 | 52 | ||
44 | await moveToFailedMoveToObjectStorageState(video) | 53 | await moveToFailedMoveToObjectStorageState(video) |
45 | await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove') | 54 | await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove') |