diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-23 08:31:02 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-23 08:31:02 +0200 |
commit | d4d0f3ba0e3577e2725f2e7e7e004478ce30a371 (patch) | |
tree | 45cc05a8f9c1ecd34842b9730ea9887b3a3f5ab9 /packages/peertube-runner/server/process/shared | |
parent | d8fe90dde2cae0f4aeea70a19f912dce55814570 (diff) | |
download | PeerTube-d4d0f3ba0e3577e2725f2e7e7e004478ce30a371.tar.gz PeerTube-d4d0f3ba0e3577e2725f2e7e7e004478ce30a371.tar.zst PeerTube-d4d0f3ba0e3577e2725f2e7e7e004478ce30a371.zip |
Don't send an error on live abort
Diffstat (limited to 'packages/peertube-runner/server/process/shared')
-rw-r--r-- | packages/peertube-runner/server/process/shared/process-live.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/peertube-runner/server/process/shared/process-live.ts b/packages/peertube-runner/server/process/shared/process-live.ts index fae79e485..e1fc0e34e 100644 --- a/packages/peertube-runner/server/process/shared/process-live.ts +++ b/packages/peertube-runner/server/process/shared/process-live.ts | |||
@@ -77,7 +77,7 @@ export class ProcessLiveRTMPHLSTranscoding { | |||
77 | try { | 77 | try { |
78 | await this.sendPendingChunks() | 78 | await this.sendPendingChunks() |
79 | } catch (err) { | 79 | } catch (err) { |
80 | this.onUpdateError(err, rej) | 80 | this.onUpdateError({ err, rej, res }) |
81 | } | 81 | } |
82 | 82 | ||
83 | const playlistName = this.getPlaylistIdFromTS(p) | 83 | const playlistName = this.getPlaylistIdFromTS(p) |
@@ -90,7 +90,7 @@ export class ProcessLiveRTMPHLSTranscoding { | |||
90 | 90 | ||
91 | tsWatcher.on('unlink', p => { | 91 | tsWatcher.on('unlink', p => { |
92 | this.sendDeletedChunkUpdate(p) | 92 | this.sendDeletedChunkUpdate(p) |
93 | .catch(err => this.onUpdateError(err, rej)) | 93 | .catch(err => this.onUpdateError({ err, rej, res })) |
94 | }) | 94 | }) |
95 | 95 | ||
96 | this.ffmpegCommand = await buildFFmpegLive().getLiveTranscodingCommand({ | 96 | this.ffmpegCommand = await buildFFmpegLive().getLiveTranscodingCommand({ |
@@ -134,23 +134,32 @@ export class ProcessLiveRTMPHLSTranscoding { | |||
134 | 134 | ||
135 | // --------------------------------------------------------------------------- | 135 | // --------------------------------------------------------------------------- |
136 | 136 | ||
137 | private onUpdateError (err: Error, reject: (reason?: any) => void) { | 137 | private onUpdateError (options: { |
138 | err: Error | ||
139 | res: () => void | ||
140 | rej: (reason?: any) => void | ||
141 | }) { | ||
142 | const { err, res, rej } = options | ||
143 | |||
138 | if (this.errored) return | 144 | if (this.errored) return |
139 | if (this.ended) return | 145 | if (this.ended) return |
140 | 146 | ||
141 | this.errored = true | 147 | this.errored = true |
142 | 148 | ||
143 | reject(err) | ||
144 | this.ffmpegCommand.kill('SIGINT') | 149 | this.ffmpegCommand.kill('SIGINT') |
145 | 150 | ||
146 | const type = ((err as any).res?.body as PeerTubeProblemDocument)?.code | 151 | const type = ((err as any).res?.body as PeerTubeProblemDocument)?.code |
147 | if (type === ServerErrorCode.RUNNER_JOB_NOT_IN_PROCESSING_STATE) { | 152 | if (type === ServerErrorCode.RUNNER_JOB_NOT_IN_PROCESSING_STATE) { |
148 | logger.info({ err }, 'Stopping transcoding as the job is not in processing state anymore') | 153 | logger.info({ err }, 'Stopping transcoding as the job is not in processing state anymore') |
154 | |||
155 | res() | ||
149 | } else { | 156 | } else { |
150 | logger.error({ err }, 'Cannot send update after added/deleted chunk, stopping live transcoding') | 157 | logger.error({ err }, 'Cannot send update after added/deleted chunk, stopping live transcoding') |
151 | 158 | ||
152 | this.sendError(err) | 159 | this.sendError(err) |
153 | .catch(subErr => logger.error({ err: subErr }, 'Cannot send error')) | 160 | .catch(subErr => logger.error({ err: subErr }, 'Cannot send error')) |
161 | |||
162 | rej(err) | ||
154 | } | 163 | } |
155 | 164 | ||
156 | this.cleanup() | 165 | this.cleanup() |