aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/peertube-runner
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-19 13:45:26 +0200
committerChocobozzz <me@florianbigard.com>2023-06-19 13:45:26 +0200
commita34c612f38af9c5f2c9f53931ed9df35ac834e90 (patch)
tree3d8f2b8a0d5c93dbe14a668cfe76cb974ce9ae74 /packages/peertube-runner
parent7d758898dc907b8643bab6ae2e70c3ca2a021fac (diff)
downloadPeerTube-a34c612f38af9c5f2c9f53931ed9df35ac834e90.tar.gz
PeerTube-a34c612f38af9c5f2c9f53931ed9df35ac834e90.tar.zst
PeerTube-a34c612f38af9c5f2c9f53931ed9df35ac834e90.zip
More robust runner update handler
Diffstat (limited to 'packages/peertube-runner')
-rw-r--r--packages/peertube-runner/server/process/shared/common.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/peertube-runner/server/process/shared/common.ts b/packages/peertube-runner/server/process/shared/common.ts
index 88f7c33f1..dbeb9dfc1 100644
--- a/packages/peertube-runner/server/process/shared/common.ts
+++ b/packages/peertube-runner/server/process/shared/common.ts
@@ -1,5 +1,4 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import { throttle } from 'lodash'
3import { ConfigManager, downloadFile, logger } from 'packages/peertube-runner/shared' 2import { ConfigManager, downloadFile, logger } from 'packages/peertube-runner/shared'
4import { join } from 'path' 3import { join } from 'path'
5import { buildUUID } from '@shared/extra-utils' 4import { buildUUID } from '@shared/extra-utils'
@@ -60,17 +59,26 @@ export function buildFFmpegVOD (options: {
60 ? 500 59 ? 500
61 : 60000 60 : 60000
62 61
63 const updateJobProgress = throttle((progress: number) => { 62 let progress: number
64 if (progress < 0 || progress > 100) progress = undefined
65 63
64 const interval = setInterval(() => {
66 updateTranscodingProgress({ server, job, runnerToken, progress }) 65 updateTranscodingProgress({ server, job, runnerToken, progress })
67 .catch(err => logger.error({ err }, 'Cannot send job progress')) 66 .catch(err => logger.error({ err }, 'Cannot send job progress'))
68 }, updateInterval, { trailing: false }) 67 }, updateInterval)
69 68
70 return new FFmpegVOD({ 69 return new FFmpegVOD({
71 ...getCommonFFmpegOptions(), 70 ...getCommonFFmpegOptions(),
72 71
73 updateJobProgress 72 onError: () => clearInterval(interval),
73 onEnd: () => clearInterval(interval),
74
75 updateJobProgress: arg => {
76 if (arg < 0 || arg > 100) {
77 progress = undefined
78 } else {
79 progress = arg
80 }
81 }
74 }) 82 })
75} 83}
76 84