mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-01 22:54:26 +02:00
web/runners/remux: retry to run the worker 10 times awkwardly
this is absolutely foul and really needs fixing but i guess it works for now 😭
This commit is contained in:
parent
4a1780ab7f
commit
a84b21a501
@ -36,6 +36,7 @@ export const startWorker = async ({ worker, workerId, parentId, workerArgs }: Co
|
|||||||
files,
|
files,
|
||||||
workerArgs.ffargs,
|
workerArgs.ffargs,
|
||||||
workerArgs.output,
|
workerArgs.output,
|
||||||
|
true, // resetStartCounter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -8,28 +8,41 @@ import type { FileInfo } from "$lib/types/libav";
|
|||||||
import type { CobaltQueue } from "$lib/types/queue";
|
import type { CobaltQueue } from "$lib/types/queue";
|
||||||
import type { CobaltFileReference } from "$lib/types/storage";
|
import type { CobaltFileReference } from "$lib/types/storage";
|
||||||
|
|
||||||
|
let startAttempts = 0;
|
||||||
|
|
||||||
export const runRemuxWorker = async (
|
export const runRemuxWorker = async (
|
||||||
workerId: string,
|
workerId: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
files: CobaltFileReference[],
|
files: CobaltFileReference[],
|
||||||
args: string[],
|
args: string[],
|
||||||
output: FileInfo
|
output: FileInfo,
|
||||||
|
resetStartCounter?: boolean
|
||||||
) => {
|
) => {
|
||||||
const worker = new RemuxWorker();
|
const worker = new RemuxWorker();
|
||||||
|
|
||||||
// sometimes chrome refuses to start libav wasm,
|
// sometimes chrome refuses to start libav wasm,
|
||||||
// so we check the health and kill self if it doesn't spawn
|
// so we check if it started, try 10 more times if not, and kill self if it still doesn't work
|
||||||
|
// TODO: fix the underlying issue because this is ridiculous
|
||||||
|
|
||||||
|
if (resetStartCounter) startAttempts = 0;
|
||||||
|
|
||||||
let bumpAttempts = 0;
|
let bumpAttempts = 0;
|
||||||
const startCheck = setInterval(() => {
|
const startCheck = setInterval(async () => {
|
||||||
bumpAttempts++;
|
bumpAttempts++;
|
||||||
|
|
||||||
if (bumpAttempts === 8) {
|
if (bumpAttempts === 10) {
|
||||||
killWorker(worker, unsubscribe, startCheck);
|
startAttempts++;
|
||||||
console.error("worker didn't start after 4 seconds, so it was killed");
|
if (startAttempts <= 10) {
|
||||||
|
killWorker(worker, unsubscribe, startCheck);
|
||||||
|
console.error("worker didn't start after 5 seconds, so it was killed and started again");
|
||||||
|
return await runRemuxWorker(workerId, parentId, files, args, output);
|
||||||
|
} else {
|
||||||
|
killWorker(worker, unsubscribe, startCheck);
|
||||||
|
console.error("worker didn't start after 10 attempts, so we're giving up");
|
||||||
|
|
||||||
// TODO: proper error code
|
// TODO: proper error code
|
||||||
return itemError(parentId, workerId, "worker didn't start");
|
return itemError(parentId, workerId, "worker didn't start");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user