@andersbakken/fisk 4.0.23 → 4.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scheduler/fisk-scheduler.js +11 -5
package/package.json
CHANGED
|
@@ -54243,6 +54243,7 @@ server.on("listen", (app) => {
|
|
|
54243
54243
|
setTimeout(() => process.exit(), 100);
|
|
54244
54244
|
});
|
|
54245
54245
|
app.post("/builder-command", (req, res) => {
|
|
54246
|
+
console.log("Got builder command", req.body);
|
|
54246
54247
|
if (!req.body || !req.body.builder || !req.body.command) {
|
|
54247
54248
|
res.sendStatus(404);
|
|
54248
54249
|
return;
|
|
@@ -54259,21 +54260,26 @@ server.on("listen", (app) => {
|
|
|
54259
54260
|
}
|
|
54260
54261
|
}
|
|
54261
54262
|
if (!found) {
|
|
54263
|
+
console.log("Didn't find builder", req.body);
|
|
54262
54264
|
res.sendStatus(404);
|
|
54263
54265
|
return;
|
|
54264
54266
|
}
|
|
54265
54267
|
let timedOut = false;
|
|
54266
54268
|
const id = ++nextCommandId;
|
|
54267
|
-
|
|
54269
|
+
const cmd = { type: "command", command: req.body.command, id };
|
|
54270
|
+
console.log("Sending command to builder", found.ip, found.name, cmd);
|
|
54271
|
+
found.send(cmd);
|
|
54268
54272
|
const onCommand = (message) => {
|
|
54269
|
-
|
|
54273
|
+
assert__default["default"](found);
|
|
54274
|
+
if (timedOut) {
|
|
54275
|
+
console.log("Timed out already");
|
|
54270
54276
|
return;
|
|
54271
54277
|
}
|
|
54272
54278
|
console.log("Got message from builder", found.ip, found.name, "\n", message);
|
|
54273
54279
|
if (message && typeof message === "object") {
|
|
54274
54280
|
const msg = message;
|
|
54275
54281
|
if (msg.id === id) {
|
|
54276
|
-
found.
|
|
54282
|
+
found.removeListener("command", onCommand);
|
|
54277
54283
|
clearTimeout(timeOut);
|
|
54278
54284
|
if (req.body.json) {
|
|
54279
54285
|
res.send(JSON.stringify(message, null, 4));
|
|
@@ -54287,11 +54293,11 @@ ${msg.stdout ? "stdout:\n" + msg.stdout + "\n" : ""}${msg.stderr ? "stderr:\n" +
|
|
|
54287
54293
|
}
|
|
54288
54294
|
}
|
|
54289
54295
|
};
|
|
54290
|
-
found.
|
|
54296
|
+
found.addListener("command", onCommand);
|
|
54291
54297
|
const timeOut = setTimeout(() => {
|
|
54292
54298
|
timedOut = true;
|
|
54293
54299
|
if (found) {
|
|
54294
|
-
found.
|
|
54300
|
+
found.removeListener("command", onCommand);
|
|
54295
54301
|
}
|
|
54296
54302
|
res.sendStatus(408);
|
|
54297
54303
|
}, parseInt(req.body.timeout) || 30000);
|