hotfix moment
This commit is contained in:
parent
41555424f4
commit
5a60e4be70
1 changed files with 20 additions and 4 deletions
24
api/index.js
24
api/index.js
|
@ -2,7 +2,9 @@
|
|||
|
||||
require("dotenv").config();
|
||||
const os = require("os");
|
||||
const { run } = require("../utils/image-runner.js");
|
||||
//const { run } = require("../utils/image-runner.js");
|
||||
const { Worker } = require("worker_threads");
|
||||
const path = require("path");
|
||||
const net = require("net");
|
||||
const http = require("http");
|
||||
|
||||
|
@ -184,7 +186,22 @@ const runJob = (job, sock) => {
|
|||
}
|
||||
|
||||
log(`Job ${job.uuid} started`, job.num);
|
||||
run(object).then((data) => {
|
||||
const worker = new Worker(path.join(__dirname, "../utils/image-runner.js"), {
|
||||
workerData: object
|
||||
});
|
||||
worker.on("message", (data) => {
|
||||
log(`Sending result of job ${job.uuid} back to the bot`, job.num);
|
||||
const jobObject = jobs.get(job.uuid);
|
||||
jobObject.data = data.buffer;
|
||||
jobObject.ext = data.fileExtension;
|
||||
jobs.set(job.uuid, jobObject);
|
||||
sock.write(Buffer.concat([Buffer.from([0x1]), Buffer.from(job.uuid)]), (e) => {
|
||||
if (e) return reject(e);
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
worker.on("error", reject);
|
||||
/*run(object).then((data) => {
|
||||
log(`Sending result of job ${job.uuid} back to the bot`, job.num);
|
||||
const jobObject = jobs.get(job.uuid);
|
||||
jobObject.data = data.buffer;
|
||||
|
@ -194,9 +211,8 @@ const runJob = (job, sock) => {
|
|||
if (e) return reject(e);
|
||||
return resolve();
|
||||
});
|
||||
return;
|
||||
}).catch(e => {
|
||||
reject(e);
|
||||
});
|
||||
});*/
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue