Add hang detection to FactorioServer.stop()

Attempt to detect if the Factorio server has hanged in
FactorioServer.stop() and send a second SIGTERM if this is the case.
This commit is contained in:
Hornwitser committed 2019-10-28 21:58:54 +01:00
1 parent a781c2f988
commit 246a8031c1
2 files changed
+55 -1

No files matched your search

+17
View File
@@ -1,4 +1,5 @@
const assert = require("assert").strict;
const events = require("events");
const fs = require("fs-extra");
const path = require("path");
@@ -165,5 +166,21 @@ describe("Integration of lib/factorio/server", function() {
assert(pass, "server did not output line from test scenario");
});
});
describe(".stop() hang detection", function() {
it("should detect factorio hanging on shutdown", async function() {
slowTest(this);
log(".start() for hang detection");
await server.start("test.zip");
if (!server._rconReady) {
await events.once(server, 'rcon-ready');
}
server.sendRcon("/c while true do end").catch(() => {});
await new Promise((resolve) => setTimeout(resolve, 300));
log(".stop() for hang detection");
await server.stop();
});
});
});
});