mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Keep auto paused instances paused
Every RCON command makes an auto paused Factorio server run one tick, so subspace_storage's 1 s inventory update and 5 s ping, plus a statistics_exporter gather on every Prometheus scrape, kept a server with nobody online running at about 1.3 ticks per second. The instance now records the auto_pause server setting it was started with and exposes autoPaused, true while that setting is on and no players are online, along with an autoPauseChanged hook. subspace_storage skips its timers while paused and sends a ping and inventory as soon as a player joins. statistics_exporter gathers once after the game pauses and keeps serving those values until it resumes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ebdbb1fe56
commit
11e067a933
11 files changed
+227
-19
No files matched your search
@@ -129,5 +129,30 @@ describe("subspace_storage plugin", function() {
|
||||
nodeMock.timers.reset();
|
||||
}
|
||||
});
|
||||
it("should not send commands while auto paused and catch up on unpause", async function() {
|
||||
nodeMock.timers.enable({ apis: ["setInterval", "Date"], now: 1000000 });
|
||||
const { instance: startedInstance, host } = await mock.loadInstancePlugin(instanceEntrypoint, info);
|
||||
host.connected = true;
|
||||
startedInstance.sendTo = async () => [];
|
||||
try {
|
||||
await startedInstance.hooks.start.invoke();
|
||||
startedInstance.server.rconCommands.length = 0;
|
||||
startedInstance.autoPaused = true;
|
||||
nodeMock.timers.tick(10000);
|
||||
assert.deepEqual(startedInstance.server.rconCommands, []);
|
||||
|
||||
startedInstance.autoPaused = false;
|
||||
await startedInstance.hooks.autoPauseChanged.invoke(false);
|
||||
assert.deepEqual(startedInstance.server.rconCommands, [
|
||||
"/sc __subspace_storage__ global.ticksSinceMasterPinged = 0",
|
||||
`/sc __subspace_storage__ UpdateInvData("${lib.escapeString(JSON.stringify(
|
||||
[new Item("signal-unixtime", 1010)]
|
||||
))}")`,
|
||||
]);
|
||||
} finally {
|
||||
await startedInstance.hooks.stop.invoke();
|
||||
nodeMock.timers.reset();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user