diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-25 15:05:18 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-25 18:41:17 +0100 |
commit | 94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 (patch) | |
tree | 32a9148e0e4567f0c4ffae0412cbed20b84e8873 /server/controllers/api/videos | |
parent | d765fafc3faf0db9818eb1a07161df1cb1bc0efa (diff) | |
download | PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.gz PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.zst PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.zip |
Move job queue to redis
We'll use it as cache in the future.
/!\ You'll loose your old jobs (pending jobs too) so upgrade only when
you don't have pending job anymore.
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/index.ts | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index c2fdb4f95..459795141 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | } from '../../../initializers' | 12 | } from '../../../initializers' |
13 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' | 13 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' |
14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' | 14 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' |
15 | import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler' | 15 | import { JobQueue } from '../../../lib/job-queue' |
16 | import { | 16 | import { |
17 | asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination, videosAddValidator, videosGetValidator, | 17 | asyncMiddleware, authenticate, paginationValidator, setDefaultSort, setDefaultPagination, videosAddValidator, videosGetValidator, |
18 | videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator | 18 | videosRemoveValidator, videosSearchValidator, videosSortValidator, videosUpdateValidator |
@@ -176,18 +176,9 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi | |||
176 | ) | 176 | ) |
177 | await Promise.all(tasks) | 177 | await Promise.all(tasks) |
178 | 178 | ||
179 | return sequelizeTypescript.transaction(async t => { | 179 | const videoCreated = await sequelizeTypescript.transaction(async t => { |
180 | const sequelizeOptions = { transaction: t } | 180 | const sequelizeOptions = { transaction: t } |
181 | 181 | ||
182 | if (CONFIG.TRANSCODING.ENABLED === true) { | ||
183 | // Put uuid because we don't have id auto incremented for now | ||
184 | const dataInput = { | ||
185 | videoUUID: video.uuid | ||
186 | } | ||
187 | |||
188 | await transcodingJobScheduler.createJob(t, 'videoFileOptimizer', dataInput) | ||
189 | } | ||
190 | |||
191 | const videoCreated = await video.save(sequelizeOptions) | 182 | const videoCreated = await video.save(sequelizeOptions) |
192 | // Do not forget to add video channel information to the created video | 183 | // Do not forget to add video channel information to the created video |
193 | videoCreated.VideoChannel = res.locals.videoChannel | 184 | videoCreated.VideoChannel = res.locals.videoChannel |
@@ -216,6 +207,17 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi | |||
216 | 207 | ||
217 | return videoCreated | 208 | return videoCreated |
218 | }) | 209 | }) |
210 | |||
211 | if (CONFIG.TRANSCODING.ENABLED === true) { | ||
212 | // Put uuid because we don't have id auto incremented for now | ||
213 | const dataInput = { | ||
214 | videoUUID: videoCreated.uuid | ||
215 | } | ||
216 | |||
217 | await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) | ||
218 | } | ||
219 | |||
220 | return videoCreated | ||
219 | } | 221 | } |
220 | 222 | ||
221 | async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { | 223 | async function updateVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { |