diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 | ||||
-rw-r--r-- | server/initializers/constants.ts | 10 | ||||
-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 |
5 files changed, 29 insertions, 19 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index db4f4c96f..08bee97d3 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -283,7 +283,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
283 | isNewVideo: true | 283 | isNewVideo: true |
284 | } | 284 | } |
285 | 285 | ||
286 | await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) | 286 | await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }) |
287 | } | 287 | } |
288 | 288 | ||
289 | return res.json({ | 289 | return res.json({ |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 54cd57619..ff0ade17a 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -100,36 +100,40 @@ const REMOTE_SCHEME = { | |||
100 | WS: 'wss' | 100 | WS: 'wss' |
101 | } | 101 | } |
102 | 102 | ||
103 | const JOB_ATTEMPTS: { [ id in JobType ]: number } = { | 103 | // TODO: remove 'video-file' |
104 | const JOB_ATTEMPTS: { [ id in (JobType | 'video-file') ]: number } = { | ||
104 | 'activitypub-http-broadcast': 5, | 105 | 'activitypub-http-broadcast': 5, |
105 | 'activitypub-http-unicast': 5, | 106 | 'activitypub-http-unicast': 5, |
106 | 'activitypub-http-fetcher': 5, | 107 | 'activitypub-http-fetcher': 5, |
107 | 'activitypub-follow': 5, | 108 | 'activitypub-follow': 5, |
108 | 'video-file-import': 1, | 109 | 'video-file-import': 1, |
110 | 'video-transcoding': 1, | ||
109 | 'video-file': 1, | 111 | 'video-file': 1, |
110 | 'video-import': 1, | 112 | 'video-import': 1, |
111 | 'email': 5, | 113 | 'email': 5, |
112 | 'videos-views': 1, | 114 | 'videos-views': 1, |
113 | 'activitypub-refresher': 1 | 115 | 'activitypub-refresher': 1 |
114 | } | 116 | } |
115 | const JOB_CONCURRENCY: { [ id in JobType ]: number } = { | 117 | const JOB_CONCURRENCY: { [ id in (JobType | 'video-file') ]: number } = { |
116 | 'activitypub-http-broadcast': 1, | 118 | 'activitypub-http-broadcast': 1, |
117 | 'activitypub-http-unicast': 5, | 119 | 'activitypub-http-unicast': 5, |
118 | 'activitypub-http-fetcher': 1, | 120 | 'activitypub-http-fetcher': 1, |
119 | 'activitypub-follow': 3, | 121 | 'activitypub-follow': 3, |
120 | 'video-file-import': 1, | 122 | 'video-file-import': 1, |
123 | 'video-transcoding': 1, | ||
121 | 'video-file': 1, | 124 | 'video-file': 1, |
122 | 'video-import': 1, | 125 | 'video-import': 1, |
123 | 'email': 5, | 126 | 'email': 5, |
124 | 'videos-views': 1, | 127 | 'videos-views': 1, |
125 | 'activitypub-refresher': 1 | 128 | 'activitypub-refresher': 1 |
126 | } | 129 | } |
127 | const JOB_TTL: { [ id in JobType ]: number } = { | 130 | const JOB_TTL: { [ id in (JobType | 'video-file') ]: number } = { |
128 | 'activitypub-http-broadcast': 60000 * 10, // 10 minutes | 131 | 'activitypub-http-broadcast': 60000 * 10, // 10 minutes |
129 | 'activitypub-http-unicast': 60000 * 10, // 10 minutes | 132 | 'activitypub-http-unicast': 60000 * 10, // 10 minutes |
130 | 'activitypub-http-fetcher': 60000 * 10, // 10 minutes | 133 | 'activitypub-http-fetcher': 60000 * 10, // 10 minutes |
131 | 'activitypub-follow': 60000 * 10, // 10 minutes | 134 | 'activitypub-follow': 60000 * 10, // 10 minutes |
132 | 'video-file-import': 1000 * 3600, // 1 hour | 135 | 'video-file-import': 1000 * 3600, // 1 hour |
136 | 'video-transcoding': 1000 * 3600 * 48, // 2 days, transcoding could be long | ||
133 | 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long | 137 | 'video-file': 1000 * 3600 * 48, // 2 days, transcoding could be long |
134 | 'video-import': 1000 * 3600 * 2, // hours | 138 | 'video-import': 1000 * 3600 * 2, // hours |
135 | 'email': 60000 * 10, // 10 minutes | 139 | 'email': 60000 * 10, // 10 minutes |
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', |