mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +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
@@ -644,6 +644,8 @@ The settings in `data/server-settings.example.json` of the Factorio installation
|
||||
|
||||
Changes to the following properties will be applied live if the instance is running while it is changed: `afk_autokick_interval`, `allow_commands`, `autosave_interval`, `autosave_only_on_server`, `description`, `ignore_player_limit_for_returning_players`, `max_players`, `max_upload_slots`, `max_upload_in_kilobytes_per_second`, `name`, `only_admins_can_pause_the_game`, `game_password`, `require_user_verification`, `tags`, `visibility`.
|
||||
|
||||
With `auto_pause` on, the plugins included with Clusterio stop their periodic commands while no players are online, so the game stays paused.
|
||||
|
||||
Defaults to a set of common settings filled in when the instance is created, such as `"tags": ["clusterio"]`, `"auto_pause": false` and a `name` and `description` based on the cluster and instance names.
|
||||
|
||||
|
||||
|
||||
@@ -505,6 +505,25 @@ Data out from Factorio does not have the same limits as data into Factorio, RCON
|
||||
For `send_json` it's possible that payloads greater than 4kB are received after payloads that were sent at a later point in time.
|
||||
For RCON, commands longer than 50 characters may end up being executed after shorter commands sent after it.
|
||||
|
||||
### Auto pause
|
||||
|
||||
Each RCON command makes a paused game run one tick, so commands sent on a timer keep a server with `auto_pause` on running while nobody is online.
|
||||
`instance.autoPaused` is true while the instance was started with `auto_pause` on and no players are online, and the `autoPauseChanged` hook is invoked with the new value when it changes.
|
||||
Skip periodic commands while it is true:
|
||||
|
||||
```js
|
||||
instance.hooks.start.attach(plugin.name, async () => {
|
||||
timer = setInterval(() => {
|
||||
if (!instance.autoPaused) {
|
||||
instance.sendRcon("/sc my_plugin.update()").catch(handleError);
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
```
|
||||
|
||||
Commands sent in response to events from elsewhere in the cluster are fine, they cost one tick each.
|
||||
A game paused with `game.tick_paused` does not run ticks for commands.
|
||||
|
||||
### Communicating over UDP
|
||||
|
||||
Instances can optionally exchange UDP packets with the Factorio server for low latency fire-and-forget communication, using the `--enable-lua-udp` option of Factorio.
|
||||
|
||||
Reference in new issue
Block a user