aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-22 15:02:27 +0200
committerChocobozzz <me@florianbigard.com>2023-06-29 10:19:55 +0200
commitbc3918b2aed033e1c7617c0610e2e363c9e605db (patch)
tree05ca587ae4d033d456c9e3c8cd32ce9fb15c28bd /packages
parent19aeb64b257efc4e1218786bd7debbb8dbe7a8ff (diff)
downloadPeerTube-bc3918b2aed033e1c7617c0610e2e363c9e605db.tar.gz
PeerTube-bc3918b2aed033e1c7617c0610e2e363c9e605db.tar.zst
PeerTube-bc3918b2aed033e1c7617c0610e2e363c9e605db.zip
Shuffle servers when checking available jobs
To not favour a specific instance
Diffstat (limited to 'packages')
-rw-r--r--packages/peertube-runner/server/process/shared/process-studio.ts4
-rw-r--r--packages/peertube-runner/server/process/shared/process-vod.ts20
-rw-r--r--packages/peertube-runner/server/server.ts4
3 files changed, 26 insertions, 2 deletions
diff --git a/packages/peertube-runner/server/process/shared/process-studio.ts b/packages/peertube-runner/server/process/shared/process-studio.ts
index 9c745d031..ce014495e 100644
--- a/packages/peertube-runner/server/process/shared/process-studio.ts
+++ b/packages/peertube-runner/server/process/shared/process-studio.ts
@@ -20,10 +20,14 @@ export async function processStudioTranscoding (options: ProcessOptions<RunnerJo
20 const { server, job, runnerToken } = options 20 const { server, job, runnerToken } = options
21 const payload = job.payload 21 const payload = job.payload
22 22
23 logger.info(`Downloading input file ${payload.input.videoFileUrl} for job ${job.jobToken}`)
24
23 let outputPath: string 25 let outputPath: string
24 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job }) 26 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job })
25 let tmpInputFilePath = inputPath 27 let tmpInputFilePath = inputPath
26 28
29 logger.info(`Input file ${payload.input.videoFileUrl} downloaded for job ${job.jobToken}. Running studio transcoding tasks.`)
30
27 try { 31 try {
28 for (const task of payload.tasks) { 32 for (const task of payload.tasks) {
29 const outputFilename = 'output-edition-' + buildUUID() + '.mp4' 33 const outputFilename = 'output-edition-' + buildUUID() + '.mp4'
diff --git a/packages/peertube-runner/server/process/shared/process-vod.ts b/packages/peertube-runner/server/process/shared/process-vod.ts
index 22489afd5..7c1119b50 100644
--- a/packages/peertube-runner/server/process/shared/process-vod.ts
+++ b/packages/peertube-runner/server/process/shared/process-vod.ts
@@ -1,4 +1,5 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import { logger } from 'packages/peertube-runner/shared'
2import { join } from 'path' 3import { join } from 'path'
3import { buildUUID } from '@shared/extra-utils' 4import { buildUUID } from '@shared/extra-utils'
4import { 5import {
@@ -16,8 +17,12 @@ export async function processWebVideoTranscoding (options: ProcessOptions<Runner
16 const { server, job, runnerToken } = options 17 const { server, job, runnerToken } = options
17 const payload = job.payload 18 const payload = job.payload
18 19
20 logger.info(`Downloading input file ${payload.input.videoFileUrl} for web video transcoding job ${job.jobToken}`)
21
19 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job }) 22 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job })
20 23
24 logger.info(`Downloaded input file ${payload.input.videoFileUrl} for job ${job.jobToken}. Running web video transcoding.`)
25
21 const ffmpegVod = buildFFmpegVOD({ job, server, runnerToken }) 26 const ffmpegVod = buildFFmpegVOD({ job, server, runnerToken })
22 27
23 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `output-${buildUUID()}.mp4`) 28 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `output-${buildUUID()}.mp4`)
@@ -56,7 +61,12 @@ export async function processHLSTranscoding (options: ProcessOptions<RunnerJobVO
56 const { server, job, runnerToken } = options 61 const { server, job, runnerToken } = options
57 const payload = job.payload 62 const payload = job.payload
58 63
64 logger.info(`Downloading input file ${payload.input.videoFileUrl} for HLS transcoding job ${job.jobToken}`)
65
59 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job }) 66 const inputPath = await downloadInputFile({ url: payload.input.videoFileUrl, runnerToken, job })
67
68 logger.info(`Downloaded input file ${payload.input.videoFileUrl} for job ${job.jobToken}. Running HLS transcoding.`)
69
60 const uuid = buildUUID() 70 const uuid = buildUUID()
61 71
62 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `${uuid}-${payload.output.resolution}.m3u8`) 72 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `${uuid}-${payload.output.resolution}.m3u8`)
@@ -101,9 +111,19 @@ export async function processAudioMergeTranscoding (options: ProcessOptions<Runn
101 const { server, job, runnerToken } = options 111 const { server, job, runnerToken } = options
102 const payload = job.payload 112 const payload = job.payload
103 113
114 logger.info(
115 `Downloading input files ${payload.input.audioFileUrl} and ${payload.input.previewFileUrl} ` +
116 `for audio merge transcoding job ${job.jobToken}`
117 )
118
104 const audioPath = await downloadInputFile({ url: payload.input.audioFileUrl, runnerToken, job }) 119 const audioPath = await downloadInputFile({ url: payload.input.audioFileUrl, runnerToken, job })
105 const inputPath = await downloadInputFile({ url: payload.input.previewFileUrl, runnerToken, job }) 120 const inputPath = await downloadInputFile({ url: payload.input.previewFileUrl, runnerToken, job })
106 121
122 logger.info(
123 `Downloaded input files ${payload.input.audioFileUrl} and ${payload.input.previewFileUrl} ` +
124 `for job ${job.jobToken}. Running audio merge transcoding.`
125 )
126
107 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `output-${buildUUID()}.mp4`) 127 const outputPath = join(ConfigManager.Instance.getTranscodingDirectory(), `output-${buildUUID()}.mp4`)
108 128
109 const ffmpegVod = buildFFmpegVOD({ job, server, runnerToken }) 129 const ffmpegVod = buildFFmpegVOD({ job, server, runnerToken })
diff --git a/packages/peertube-runner/server/server.ts b/packages/peertube-runner/server/server.ts
index e76131c74..5fa86fa1a 100644
--- a/packages/peertube-runner/server/server.ts
+++ b/packages/peertube-runner/server/server.ts
@@ -1,7 +1,7 @@
1import { ensureDir, readdir, remove } from 'fs-extra' 1import { ensureDir, readdir, remove } from 'fs-extra'
2import { join } from 'path' 2import { join } from 'path'
3import { io, Socket } from 'socket.io-client' 3import { io, Socket } from 'socket.io-client'
4import { pick, wait } from '@shared/core-utils' 4import { pick, shuffle, wait } from '@shared/core-utils'
5import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' 5import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
6import { PeerTubeServer as PeerTubeServerCommand } from '@shared/server-commands' 6import { PeerTubeServer as PeerTubeServerCommand } from '@shared/server-commands'
7import { ConfigManager } from '../shared' 7import { ConfigManager } from '../shared'
@@ -175,7 +175,7 @@ export class RunnerServer {
175 175
176 let hadAvailableJob = false 176 let hadAvailableJob = false
177 177
178 for (const server of this.servers) { 178 for (const server of shuffle([ ...this.servers ])) {
179 try { 179 try {
180 logger.info('Checking available jobs on ' + server.url) 180 logger.info('Checking available jobs on ' + server.url)
181 181