mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Rewrite Factorio server shutdown logic
Rewrite shutdown logic for Factorio servers to send a /quit command via RCON for both Linux and Windows when stopping a server to avoid having two confusingly intermixed code paths for Windows and Unix systems. This makes shutdown on Windows tell clients the server shut down instead of abruptly stoping to respond.
This commit is contained in:
1 parent
36fc2ac1db
commit
7ff06f2b96
6 files changed
+179
-94
No files matched your search
+12
-8
@@ -211,24 +211,28 @@ describe("host/server", function() {
|
||||
|
||||
describe(".stop()", function() {
|
||||
it("should handle server quitting on its own during stop", async function() {
|
||||
server.hangTimeoutMs = 20;
|
||||
server.shutdownTimeoutMs = 20;
|
||||
server._server = new events.EventEmitter();
|
||||
server._server.kill = () => true;
|
||||
server._state = "running";
|
||||
server._rconReady = true;
|
||||
server._rconReady = false;
|
||||
server._rconClient = {
|
||||
async sendRcon() { },
|
||||
async end() {
|
||||
server._rconClient = null;
|
||||
process.nextTick(() => {
|
||||
server.emit("_quitting");
|
||||
server._server.emit("exit");
|
||||
});
|
||||
},
|
||||
};
|
||||
server._watchExit();
|
||||
|
||||
await server.stop();
|
||||
await wait(21); // Wait until after hang timeout
|
||||
const stop = server.stop();
|
||||
stop.catch(() => {});
|
||||
process.nextTick(() => {
|
||||
server.emit("rcon-ready");
|
||||
server._server.emit("exit");
|
||||
});
|
||||
|
||||
await stop;
|
||||
await wait(21); // Wait until after shutdown timeout
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user