diff --git a/server.js b/server.js index 4a6a630319a3c4865be9b8155930565e6732ee2f..cb72d75f0774a934ac72b9752cb008a777fee560 100644 --- a/server.js +++ b/server.js @@ -1245,6 +1245,7 @@ function homePage(req, res) { } readyEmitter.on("readyCheck", function () { + console.log(readyChecklist) // All done constructing the page. Send it to the requester. if (Object.values(readyChecklist).every((o) => o === true)) { fetch(`http://${domain}:${webPort}/templates/index.mustache`) @@ -1275,24 +1276,28 @@ function homePage(req, res) { readyChecklist.localJobs = true; readyEmitter.emit('readyCheck'); } - } - if (jobQueue.length != 0) { - readyEmitter.on("localQueueItemFinished", () => { - if ((queueFinishedCount += 1) == jobQueue.length) { - view.queuedJobs += "</ul></br>"; - readyChecklist.localQueue = true; - readyEmitter.emit('readyCheck'); - } - }); - - view.queuedJobs += "<h4>Queued:</h4><ul>"; - for (let i = jobQueue.length - 1; i >= 0; i--) { - view.queuedJobs += toolbox.jobFormatter(jobQueue[i], hosts, (job) => { - view.queuedJobs += job; - readyEmitter.emit("localQueueItemFinished"); + if (jobQueue.length != 0) { + readyEmitter.on("localQueueItemFinished", () => { + if ((queueFinishedCount += 1) == jobQueue.length) { + view.queuedJobs += "</ul></br>"; + readyChecklist.localQueue = true; + readyEmitter.emit('readyCheck'); + } }); + + view.queuedJobs += "<h4>Queued:</h4><ul>"; + for (let i = jobQueue.length - 1; i >= 0; i--) { + view.queuedJobs += toolbox.jobFormatter(jobQueue[i], hosts, (job) => { + view.queuedJobs += job; + readyEmitter.emit("localQueueItemFinished"); + }); + } + } else { + readyChecklist.localQueue = true; + readyEmitter.emit('readyCheck'); } } else { + readyChecklist.localJobs = true; readyChecklist.localQueue = true; readyEmitter.emit('readyCheck'); } @@ -1316,7 +1321,10 @@ function homePage(req, res) { }) } } else { + view.remoteJobs += `💤... No running jobs`; + readyChecklist.remoteJobs = true; + readyEmitter.emit('readyCheck'); } if (remoteQueuedJobs.length != 0) { @@ -1335,6 +1343,9 @@ function homePage(req, res) { readyEmitter.emit("remoteQueueFinished"); }); } + } else { + readyChecklist.remoteQueue = true; + readyEmitter.emit('readyCheck'); } } else {