Add queued image jobs to server selection logic

This commit is contained in:
Essem 2021-09-01 00:21:13 -05:00
parent 2421c310e3
commit fec3d7303c
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 12 additions and 3 deletions

View file

@ -119,7 +119,11 @@ httpServer.on("request", async (req, res) => {
const reqUrl = new URL(req.url, `http://${req.headers.host}`);
if (reqUrl.pathname === "/status" && req.method === "GET") {
log(`Sending server status to ${req.socket.remoteAddress}:${req.socket.remotePort} via HTTP`);
return res.end(Buffer.from((MAX_JOBS - jobAmount).toString()));
const statusObject = {
load: MAX_JOBS - jobAmount,
queued: queue.length
};
return res.end(JSON.stringify(statusObject));
} else if (reqUrl.pathname === "/running" && req.method === "GET") {
log(`Sending currently running jobs to ${req.socket.remoteAddress}:${req.socket.remotePort} via HTTP`);
const keys = jobs.keys();