Re-add image job timeout, split dockerfiles, removed api from docker-compose, more fixes

This commit is contained in:
TheEssem 2021-05-10 22:59:19 -05:00
parent f0734bba00
commit 2b810c7c86
10 changed files with 90 additions and 128 deletions

View file

@ -188,8 +188,13 @@ const runJob = (job, sock) => {
const worker = new Worker(path.join(__dirname, "../utils/image-runner.js"), {
workerData: object
});
const timeout = setTimeout(() => {
worker.terminate();
reject(new Error("Job timed out"));
}, 900000);
log(`Job ${job.uuid} started`, job.num);
worker.once("message", (data) => {
clearTimeout(timeout);
log(`Sending result of job ${job.uuid} back to the bot`, job.num);
const jobObject = jobs.get(job.uuid);
jobObject.data = data.buffer;
@ -200,7 +205,10 @@ const runJob = (job, sock) => {
return resolve();
});
});
worker.once("error", reject);
worker.once("error", (e) => {
clearTimeout(timeout);
reject(e);
});
/*run(object).then((data) => {
log(`Sending result of job ${job.uuid} back to the bot`, job.num);
const jobObject = jobs.get(job.uuid);