diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 17:00:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 17:00:08 +0100 |
commit | a0327eedb0136c4ba7358df80b75cc56bd25ffb8 (patch) | |
tree | 7de1486d3671e85ce53c650f74f70dbf3d8845b2 /server/lib/job-queue | |
parent | 1ed9b8ee69ba42b2be70512eb8df239be4676674 (diff) | |
download | PeerTube-a0327eedb0136c4ba7358df80b75cc56bd25ffb8.tar.gz PeerTube-a0327eedb0136c4ba7358df80b75cc56bd25ffb8.tar.zst PeerTube-a0327eedb0136c4ba7358df80b75cc56bd25ffb8.zip |
Rename video-file job to video-transcoding
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 2 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts (renamed from server/lib/job-queue/handlers/video-file.ts) | 18 | ||||
-rw-r--r-- | server/lib/job-queue/job-queue.ts | 16 |
3 files changed, 21 insertions, 15 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 12004dcd7..d96bfdf43 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -207,7 +207,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
207 | isNewVideo: true | 207 | isNewVideo: true |
208 | } | 208 | } |
209 | 209 | ||
210 | await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) | 210 | await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) |
211 | } | 211 | } |
212 | 212 | ||
213 | } catch (err) { | 213 | } catch (err) { |
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 3a867b77f..ceee83f13 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -11,7 +11,7 @@ import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | |||
11 | import { generateHlsPlaylist, importVideoFile, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' | 11 | import { generateHlsPlaylist, importVideoFile, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' |
12 | import { Notifier } from '../../notifier' | 12 | import { Notifier } from '../../notifier' |
13 | 13 | ||
14 | export type VideoFilePayload = { | 14 | export type VideoTranscodingPayload = { |
15 | videoUUID: string | 15 | videoUUID: string |
16 | resolution?: VideoResolution | 16 | resolution?: VideoResolution |
17 | isNewVideo?: boolean | 17 | isNewVideo?: boolean |
@@ -41,8 +41,8 @@ async function processVideoFileImport (job: Bull.Job) { | |||
41 | return video | 41 | return video |
42 | } | 42 | } |
43 | 43 | ||
44 | async function processVideoFile (job: Bull.Job) { | 44 | async function processVideoTranscoding (job: Bull.Job) { |
45 | const payload = job.data as VideoFilePayload | 45 | const payload = job.data as VideoTranscodingPayload |
46 | logger.info('Processing video file in job %d.', job.id) | 46 | logger.info('Processing video file in job %d.', job.id) |
47 | 47 | ||
48 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) | 48 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID) |
@@ -83,7 +83,7 @@ async function onHlsPlaylistGenerationSuccess (video: VideoModel) { | |||
83 | }) | 83 | }) |
84 | } | 84 | } |
85 | 85 | ||
86 | async function onVideoFileTranscoderOrImportSuccess (video: VideoModel, payload?: VideoFilePayload) { | 86 | async function onVideoFileTranscoderOrImportSuccess (video: VideoModel, payload?: VideoTranscodingPayload) { |
87 | if (video === undefined) return undefined | 87 | if (video === undefined) return undefined |
88 | 88 | ||
89 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { | 89 | const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => { |
@@ -118,7 +118,7 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel, payload? | |||
118 | await createHlsJobIfEnabled(payload) | 118 | await createHlsJobIfEnabled(payload) |
119 | } | 119 | } |
120 | 120 | ||
121 | async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: VideoFilePayload) { | 121 | async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: VideoTranscodingPayload) { |
122 | if (videoArg === undefined) return undefined | 122 | if (videoArg === undefined) return undefined |
123 | 123 | ||
124 | // Outside the transaction (IO on disk) | 124 | // Outside the transaction (IO on disk) |
@@ -148,7 +148,7 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: Video | |||
148 | resolution | 148 | resolution |
149 | } | 149 | } |
150 | 150 | ||
151 | const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) | 151 | const p = JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) |
152 | tasks.push(p) | 152 | tasks.push(p) |
153 | } | 153 | } |
154 | 154 | ||
@@ -182,13 +182,13 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: Video | |||
182 | // --------------------------------------------------------------------------- | 182 | // --------------------------------------------------------------------------- |
183 | 183 | ||
184 | export { | 184 | export { |
185 | processVideoFile, | 185 | processVideoTranscoding, |
186 | processVideoFileImport | 186 | processVideoFileImport |
187 | } | 187 | } |
188 | 188 | ||
189 | // --------------------------------------------------------------------------- | 189 | // --------------------------------------------------------------------------- |
190 | 190 | ||
191 | function createHlsJobIfEnabled (payload?: VideoFilePayload) { | 191 | function createHlsJobIfEnabled (payload?: VideoTranscodingPayload) { |
192 | // Generate HLS playlist? | 192 | // Generate HLS playlist? |
193 | if (payload && CONFIG.TRANSCODING.HLS.ENABLED) { | 193 | if (payload && CONFIG.TRANSCODING.HLS.ENABLED) { |
194 | const hlsTranscodingPayload = { | 194 | const hlsTranscodingPayload = { |
@@ -199,6 +199,6 @@ function createHlsJobIfEnabled (payload?: VideoFilePayload) { | |||
199 | generateHlsPlaylist: true | 199 | generateHlsPlaylist: true |
200 | } | 200 | } |
201 | 201 | ||
202 | return JobQueue.Instance.createJob({ type: 'video-file', payload: hlsTranscodingPayload }) | 202 | return JobQueue.Instance.createJob({ type: 'video-transcoding', payload: hlsTranscodingPayload }) |
203 | } | 203 | } |
204 | } | 204 | } |
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index ba9cbe0d9..e73042163 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -7,7 +7,12 @@ import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from | |||
7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' | 8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' |
9 | import { EmailPayload, processEmail } from './handlers/email' | 9 | import { EmailPayload, processEmail } from './handlers/email' |
10 | import { processVideoFile, processVideoFileImport, VideoFileImportPayload, VideoFilePayload } from './handlers/video-file' | 10 | import { |
11 | processVideoFileImport, | ||
12 | processVideoTranscoding, | ||
13 | VideoFileImportPayload, | ||
14 | VideoTranscodingPayload | ||
15 | } from './handlers/video-transcoding' | ||
11 | import { ActivitypubFollowPayload, processActivityPubFollow } from './handlers/activitypub-follow' | 16 | import { ActivitypubFollowPayload, processActivityPubFollow } from './handlers/activitypub-follow' |
12 | import { processVideoImport, VideoImportPayload } from './handlers/video-import' | 17 | import { processVideoImport, VideoImportPayload } from './handlers/video-import' |
13 | import { processVideosViews } from './handlers/video-views' | 18 | import { processVideosViews } from './handlers/video-views' |
@@ -19,19 +24,20 @@ type CreateJobArgument = | |||
19 | { type: 'activitypub-http-fetcher', payload: ActivitypubHttpFetcherPayload } | | 24 | { type: 'activitypub-http-fetcher', payload: ActivitypubHttpFetcherPayload } | |
20 | { type: 'activitypub-follow', payload: ActivitypubFollowPayload } | | 25 | { type: 'activitypub-follow', payload: ActivitypubFollowPayload } | |
21 | { type: 'video-file-import', payload: VideoFileImportPayload } | | 26 | { type: 'video-file-import', payload: VideoFileImportPayload } | |
22 | { type: 'video-file', payload: VideoFilePayload } | | 27 | { type: 'video-transcoding', payload: VideoTranscodingPayload } | |
23 | { type: 'email', payload: EmailPayload } | | 28 | { type: 'email', payload: EmailPayload } | |
24 | { type: 'video-import', payload: VideoImportPayload } | | 29 | { type: 'video-import', payload: VideoImportPayload } | |
25 | { type: 'activitypub-refresher', payload: RefreshPayload } | | 30 | { type: 'activitypub-refresher', payload: RefreshPayload } | |
26 | { type: 'videos-views', payload: {} } | 31 | { type: 'videos-views', payload: {} } |
27 | 32 | ||
28 | const handlers: { [ id in JobType ]: (job: Bull.Job) => Promise<any>} = { | 33 | const handlers: { [ id in (JobType | 'video-file') ]: (job: Bull.Job) => Promise<any>} = { |
29 | 'activitypub-http-broadcast': processActivityPubHttpBroadcast, | 34 | 'activitypub-http-broadcast': processActivityPubHttpBroadcast, |
30 | 'activitypub-http-unicast': processActivityPubHttpUnicast, | 35 | 'activitypub-http-unicast': processActivityPubHttpUnicast, |
31 | 'activitypub-http-fetcher': processActivityPubHttpFetcher, | 36 | 'activitypub-http-fetcher': processActivityPubHttpFetcher, |
32 | 'activitypub-follow': processActivityPubFollow, | 37 | 'activitypub-follow': processActivityPubFollow, |
33 | 'video-file-import': processVideoFileImport, | 38 | 'video-file-import': processVideoFileImport, |
34 | 'video-file': processVideoFile, | 39 | 'video-transcoding': processVideoTranscoding, |
40 | 'video-file': processVideoTranscoding, // TODO: remove it (changed in 1.3) | ||
35 | 'email': processEmail, | 41 | 'email': processEmail, |
36 | 'video-import': processVideoImport, | 42 | 'video-import': processVideoImport, |
37 | 'videos-views': processVideosViews, | 43 | 'videos-views': processVideosViews, |
@@ -44,7 +50,7 @@ const jobTypes: JobType[] = [ | |||
44 | 'activitypub-http-fetcher', | 50 | 'activitypub-http-fetcher', |
45 | 'activitypub-http-unicast', | 51 | 'activitypub-http-unicast', |
46 | 'email', | 52 | 'email', |
47 | 'video-file', | 53 | 'video-transcoding', |
48 | 'video-file-import', | 54 | 'video-file-import', |
49 | 'video-import', | 55 | 'video-import', |
50 | 'videos-views', | 56 | 'videos-views', |