[PR #551] [MERGED] horizon-server: server.toml, init, and a supervisor that runs the game #2636

Closed
opened 2026-11-02 15:57:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/551
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: feat/horizon-server


📝 Commits (2)

  • 9d21209 horizon-server: server.toml, init, and a supervisor that runs the game
  • 07f7e3a Merge remote-tracking branch 'origin/main' into srv-fix

📊 Changes

19 files changed (+1561 additions, -6 deletions)

View changed files

📝 Cargo.lock (+24 -0)
📝 Cargo.toml (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/lib.rs (+1 -1)
➕ crates/horizon-server-files/Cargo.toml (+16 -0)
📝 crates/horizon-server-files/src/eula.rs (+6 -1)
📝 crates/horizon-server-files/src/java_properties.rs (+0 -0)
📝 crates/horizon-server-files/src/json.rs (+0 -0)
📝 crates/horizon-server-files/src/lib.rs (+3 -3)
📝 crates/horizon-server-files/src/properties.rs (+0 -0)
📝 crates/horizon-server-files/src/user_lists.rs (+0 -0)
➕ crates/horizon-server/Cargo.toml (+24 -0)
➕ crates/horizon-server/src/config.rs (+515 -0)
➕ crates/horizon-server/src/engine.rs (+127 -0)
➕ crates/horizon-server/src/init.rs (+276 -0)
➕ crates/horizon-server/src/lists.rs (+153 -0)
➕ crates/horizon-server/src/main.rs (+117 -0)
➕ crates/horizon-server/src/signals.rs (+41 -0)
➕ crates/horizon-server/src/supervisor.rs (+255 -0)

📄 Description

First code PR of docs/server.md (section 11, PR 2a): a horizon-server binary that an owner runs instead of horizon-client --dedicated.

What it does

  • crates/horizon-server, a small supervisor binary (1.5–2 MB). It links only the light crates, plus serde, toml and toml_edit: no wgpu, winit, cpal or gilrs. It runs the game headless (horizon-client --dedicated) as its engine, in a child process.
  • server.toml: one typed config file ([server], [world], [properties] for any other vanilla key, [engine]). Its defaults are vanilla 26.3's, and a test checks each one. Before every start the supervisor writes server.properties from it, so the engine still reads exactly vanilla's files. Keys the game changes in play (/whitelist on) are copied back into the TOML, and the owner's comments are kept. Unknown keys and values vanilla would refuse are errors.
  • horizon-server init: the first run, interactive on a terminal or driven by flags. It covers the EULA (only a yes writes eula=true), the world, the seed, the port, the whitelist, the first players and the first op, and finds the prepared game files. An existing server.properties is imported, and the original is kept as server.properties.imported. import FILE does the same on its own.
  • horizon-server run: the server in the foreground, with the console on stdin.
    • Ctrl-C or SIGTERM stops the game cleanly (it saves first); a second one stops it at once.
    • A crash is restarted after 5 s, doubling up to 5 min, and it gives up after 5 crashes in 10 min.
    • One supervisor per folder, through a file lock.
  • op, deop, whitelist on a stopped server, with vanilla's messages.
  • crates/horizon-server-files: the vanilla file code (server.properties, eula.txt, the JSON lists) moved out of the client unchanged, so both binaries share it. The client re-exports it as horizon_client::server.

Tested by hand (Mac mini)

init → run, then a Horizon client joined. kill -9 on the engine restarted it after 5 s. SIGTERM stopped it with a save, op and whitelist changed the files, and an imported vanilla server.properties round-tripped.

Checks

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean on every branch of the stack.
  • Tests: cargo test -p horizon-server -p horizon-server-files pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad).
  • Parity at the stack's tip (2a–3), rebased on b4ad6538:
    • tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage: 5 passed, 0 failed. dedicated_server includes vanilla's protocol client joining Horizon's server.
    • The full --changed origin/main set (309 harnesses, because the client crate changes) had 60 passed, 0 failed when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest.

Stack: this → #552 → #553 → #554 → #555 → #556, each based on the one before; the design is #557.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/551 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/horizon-server` --- ### 📝 Commits (2) - [`9d21209`](https://github.com/horizon-rust/horizon/commit/9d21209ae8c4e6f788955abab69e7b96d1ef3237) horizon-server: server.toml, init, and a supervisor that runs the game - [`07f7e3a`](https://github.com/horizon-rust/horizon/commit/07f7e3aeab80a1d3d3c76ef5b643eaaf1fa48fde) Merge remote-tracking branch 'origin/main' into srv-fix ### 📊 Changes **19 files changed** (+1561 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+24 -0) 📝 `Cargo.toml` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -1) ➕ `crates/horizon-server-files/Cargo.toml` (+16 -0) 📝 `crates/horizon-server-files/src/eula.rs` (+6 -1) 📝 `crates/horizon-server-files/src/java_properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/json.rs` (+0 -0) 📝 `crates/horizon-server-files/src/lib.rs` (+3 -3) 📝 `crates/horizon-server-files/src/properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/user_lists.rs` (+0 -0) ➕ `crates/horizon-server/Cargo.toml` (+24 -0) ➕ `crates/horizon-server/src/config.rs` (+515 -0) ➕ `crates/horizon-server/src/engine.rs` (+127 -0) ➕ `crates/horizon-server/src/init.rs` (+276 -0) ➕ `crates/horizon-server/src/lists.rs` (+153 -0) ➕ `crates/horizon-server/src/main.rs` (+117 -0) ➕ `crates/horizon-server/src/signals.rs` (+41 -0) ➕ `crates/horizon-server/src/supervisor.rs` (+255 -0) </details> ### 📄 Description First code PR of [docs/server.md](https://github.com/ludovic111/horizon/pull/557) (section 11, PR 2a): a `horizon-server` binary that an owner runs instead of `horizon-client --dedicated`. ## What it does - **`crates/horizon-server`**, a small supervisor binary (1.5–2 MB). It links only the light crates, plus serde, toml and toml_edit: no wgpu, winit, cpal or gilrs. It runs the game headless (`horizon-client --dedicated`) as its engine, in a child process. - **`server.toml`**: one typed config file (`[server]`, `[world]`, `[properties]` for any other vanilla key, `[engine]`). Its defaults are vanilla 26.3's, and a test checks each one. Before every start the supervisor writes `server.properties` from it, so the engine still reads exactly vanilla's files. Keys the game changes in play (`/whitelist on`) are copied back into the TOML, and the owner's comments are kept. Unknown keys and values vanilla would refuse are errors. - **`horizon-server init`**: the first run, interactive on a terminal or driven by flags. It covers the EULA (only a yes writes `eula=true`), the world, the seed, the port, the whitelist, the first players and the first op, and finds the prepared game files. An existing `server.properties` is imported, and the original is kept as `server.properties.imported`. `import FILE` does the same on its own. - **`horizon-server run`**: the server in the foreground, with the console on stdin. - Ctrl-C or SIGTERM stops the game cleanly (it saves first); a second one stops it at once. - A crash is restarted after 5 s, doubling up to 5 min, and it gives up after 5 crashes in 10 min. - One supervisor per folder, through a file lock. - **`op`, `deop`, `whitelist`** on a stopped server, with vanilla's messages. - **`crates/horizon-server-files`**: the vanilla file code (server.properties, eula.txt, the JSON lists) moved out of the client unchanged, so both binaries share it. The client re-exports it as `horizon_client::server`. ## Tested by hand (Mac mini) `init` → `run`, then a Horizon client joined. `kill -9` on the engine restarted it after 5 s. SIGTERM stopped it with a save, `op` and `whitelist` changed the files, and an imported vanilla `server.properties` round-tripped. ## Checks - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean on every branch of the stack. - Tests: `cargo test -p horizon-server -p horizon-server-files` pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad). - Parity at the stack's tip (2a–3), rebased on b4ad6538: - `tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage`: **5 passed, 0 failed**. `dedicated_server` includes vanilla's protocol client joining Horizon's server. - The full `--changed origin/main` set (309 harnesses, because the client crate changes) had **60 passed, 0 failed** when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest. Stack: this → #552 → #553 → #554 → #555 → #556, each based on the one before; the design is #557. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:50 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2636
No description provided.