Skip to content

Add exp_auto_restart plugin - #477

Open
bbassie wants to merge 1 commit into
explosivegaming:mainfrom
bbassie:feature/auto-restart
Open

bbassie wants to merge 1 commit into
explosivegaming:mainfrom
bbassie:feature/auto-restart

Conversation

@bbassie

@bbassie bbassie commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Adds exp_auto_restart (@expcluster/auto-restart), a controller-only plugin that restarts hosts, and optionally the controller, which report "Restart Required" once no players have been online for a configurable time.

How it works. Every 10 s it walks the controller's system info. A connected host with restartRequired and canRestart whose running instances have had no players for exp_auto_restart.idle_seconds gets HostRestartRequest, the same request the web UI button sends. Players are counted from the users online on instances with status running, so stale online sets after a host crash do not hold anything back. When the host reconnects and reports its instances, the ones that were running are started again; instances with instance.auto_start are left to the host. Each host process is asked at most once, keyed on its process start time, so a stale system info poll cannot trigger a second restart. A refusal from the host (no --can-restart, downgrade) is logged once and not retried, transport errors retry on the next check.

Config, all on the controller: idle_seconds (300), scope (host or cluster, whether players on other hosts also hold back a restart), start_instances (true), restart_controller (false, restarts the controller when the whole cluster is idle, after the same downgrade check the web UI does).

It uses the function-style default export that clusterio master now documents, so it loads without the "deprecated class export" warning the other plugins get.

Testing. 53 tap assertions around a real Controller with sendTo stubbed: idle tracking, the idle threshold, once per process, canRestart false, cluster scope, refusal versus transport errors, instance restart after reconnect, pending expiry, and the controller path. Smoke tested in a standalone dev cluster with a host in a restart loop and a Factorio 2.1.19 instance: after a restart-required config change the host was restarted once the idle time passed, came back in 2 s and the instance was started again, with no second restart.

Notes.

  • Clusterio does not yet flag a restart after a plugin install, only after updates and restart-flagged config changes. Mark restart required after installing a new plugin clusterio/clusterio#1042 fixes that. Until it lands this plugin will not react to plugin installs, the README says so.
  • Unrelated to this PR: main does not build against clusterio master since clusterio/clusterio@7122cbcc (typed hook system). exp_roles web/index.tsx fails on PluginExtensionProps and exp_scenario on controller.plugins, so Node CI will be red until that is caught up.

🤖 Generated with Claude Code

Restarts hosts, and optionally the controller, that report a pending
restart once no players have been online for a configurable time. Only
loaded on the controller: it counts players from the users online on
running instances, sends HostRestartRequest through the existing core
path, and starts the instances that were running once the host reports
back. Each host process is asked at most once, keyed on its process
start time, so a stale system info poll cannot trigger a second restart.

Uses the function-style entrypoint clusterio now documents, so it loads
without the deprecated class export warning.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant