-
Notifications
You must be signed in to change notification settings - Fork 0
Server Management
This page covers install, start, stop, restart, update, console interaction, automation, and Minecraft-specific management details.
Server Manager supports three types of server installations:
Steam Dedicated Servers: Installation is performed through SteamCMD, Valve's command-line tool for downloading and updating Steam game servers. The process:
- The user provides the Steam App ID, server name, and installation directory.
- Server Manager invokes SteamCMD with the appropriate parameters:
steamcmd +login <username> +force_install_dir <dir> +app_update <appid> validate +quit. - SteamCMD handles downloading the server files. Server Manager monitors the process and handles 40+ error codes.
- Login can be anonymous (for free dedicated servers) or authenticated (for servers requiring a Steam account). Steam Guard TOTP codes are supported.
- After installation, the server configuration is saved to the database with all metadata.
Minecraft Servers: Minecraft server installation supports four modloaders:
- Vanilla — Downloads the official server JAR from Mojang's version manifest.
- Fabric — Downloads from the Fabric meta API.
- Forge — Downloads from the Forge promotions/downloads CDN.
- NeoForge — Downloads from the NeoForge API.
The installer also handles EULA auto-acceptance, launch script creation (with appropriate Java arguments), and server detection.
Custom Servers: You can add any executable as a managed server by providing the executable path and working directory.
Starting a server (ServerManager.start_server_advanced()) involves:
- Corruption Detection — Checks the installation directory for signs of corrupted or incomplete installations.
-
Executable Resolution — Handles multiple executable types: batch scripts (
.bat,.cmd), executables (.exe), and Java JARs (.jar). For batch scripts, the command is wrapped withcmd.exe /c. For JAR files, the Java executable is used. -
Process Creation — The server process is started with
subprocess.Popen. Console window visibility is controlled by thehideServerConsolesconfiguration option. Stdin, stdout, and stderr are captured for console interaction. - Retry Logic — If the first start attempt fails, up to 3 retries are attempted with different strategies (e.g., adjusting working directory, retrying with different executable detection).
- Process Registration — The PID, process creation time, and status are recorded in the database.
- Stdin Relay Setup — The command input infrastructure (named pipes, command queue) is initialised for the new server process.
- Post-Start Commands — If a start command is configured in the automation settings, it is executed on the server after a brief startup delay.
Stopping a server (ServerManager.stop_server_advanced()) uses a multi-strategy graceful shutdown approach:
-
Stop Command via Stdin — If a stop command is configured (e.g.,
stop,exit,quit), it is sent to the server via the stdin relay infrastructure. - SIGTERM — A terminate signal is sent to the process.
- Window Close — On Windows, attempts to close the process's main window.
- Ctrl+C Event — Sends a CTRL_C_EVENT to the process group.
-
Force Kill — If none of the graceful methods succeed within the timeout period, the process is forcefully terminated using
taskkill /F /T(with child processes).
After the process exits, the PID and status are updated in the database, and stdin relay resources are cleaned up.
Restarting a server (ServerManager.restart_server_advanced()) combines the stop and start sequences:
- Initiate stop with the graceful shutdown sequence.
- Wait for the process to fully exit.
- Initiate start with the standard startup sequence.
- A callback function can be provided for progress reporting.
If pre-restart warnings are configured, the restart operation first sends countdown warnings at the configured intervals before initiating the stop.
The update system (Modules/updates/server_updates.py, ServerUpdateManager) provides both on-demand and scheduled update checking:
Manual Update Check:
For Steam servers, the update checker queries SteamCMD's app_info_print command with a 2-minute timeout to compare the installed build ID against the latest available build ID. If a newer version is available, the server can be updated.
Automatic Update Process:
- Stop the server (if running).
- Run SteamCMD to update the server files (
+app_update <appid> validate). - Restart the server.
- The
in_progressflag prevents concurrent update operations on the same server.
Scheduled Updates:
- Global Schedule — A global update schedule can be configured to check all servers at a specific time window. The system supports daily and weekly schedules with a 30-minute time window for flexibility.
- Per-Server Schedule — Individual servers can have their own update schedules that override the global schedule.
- Scattered Restarts — To avoid restarting all servers simultaneously, a hash of the server name is used to compute a consistent time offset, scattering restarts across the schedule window.
Pre-Restart Warnings:
Before restarting a server for updates, warning messages are broadcast to connected players at configurable intervals. The default intervals are 30, 15, 10, 5, and 1 minutes before the restart. The warning message template supports a {message} placeholder that is replaced with the remaining time. Warning delivery uses the shared send_command_to_server() utility from common.py, which tries the persistent stdin pipe first and falls back to the file-based command queue.
Batch Updates:
The update_all_steam_servers() method checks and updates all Steam servers sequentially with a 2-second delay between servers to avoid overwhelming the system or SteamCMD.
See Section 7.4: Server Console for the full description of the console system and its five command delivery methods.
The Server Automation system (Modules/services/server_automation.py, ServerAutomationManager) runs as a background process and handles:
MOTD Broadcasting:
- A background thread checks all server configurations every 60 seconds.
- For each server with MOTD enabled (interval > 0 and message non-empty), it checks if enough time has elapsed since the last broadcast.
- If the server is running and it is time, the MOTD command is sent to the server with
{message}replaced by the configured message text. - Broadcast timestamps are tracked per-server to maintain accurate intervals.
Restart Warnings:
- When a scheduled restart is approaching, warning messages are sent at the configured intervals (e.g., "Server restarting in 30 minutes", "Server restarting in 15 minutes", etc.).
- The warning command and message template are per-server settings.
- Warning delivery uses the shared
send_command_to_server()utility fromcommon.py.
Start Commands:
- After a server starts, configured start commands are automatically executed.
- This is useful for servers that need initialisation commands after boot.
Server Manager supports four Minecraft modloaders:
-
Vanilla — The official Mojang server JAR. Downloaded directly from Mojang's version manifest API (
https://launchermeta.mojang.com/mc/game/version_manifest_v2.json). Supports all release and snapshot versions. -
Fabric — A lightweight, modular modloader. Downloaded from the Fabric meta API (
https://meta.fabricmc.net/). Popular for performance-focused mod packs. -
Forge — The most established modloader for Minecraft. Downloaded from the Forge promotions API (
https://files.minecraftforge.net/). Supports a vast ecosystem of mods. -
NeoForge — A community fork of Forge with modern API improvements. Downloaded from the NeoForge API (
https://maven.neoforged.net/).
Different Minecraft versions require different Java versions. Server Manager includes automatic Java detection and version matching:
| Minecraft Version | Required Java Version |
|---|---|
| 1.16 and earlier | Java 8 |
| 1.17 | Java 16 |
| 1.18 – 1.20 | Java 17 |
| 1.21 and later | Java 21 |
Java Detection: The detect_java_installations() function scans common Windows installation paths:
-
JAVA_HOMEenvironment variable C:\Program Files\Java\*C:\Program Files (x86)\Java\*C:\Program Files\Eclipse Adoptium\*C:\Program Files\Amazon Corretto\*C:\Program Files\Microsoft\*- System PATH directories
For each detected installation, the function extracts the version string and validates the Java binary.
Compatibility Checking: check_java_compatibility() compares a detected Java installation against the requirements for a specific Minecraft version and reports whether it is compatible, along with recommendations if not.
The Java Configurator (Modules/updates/java_configurator.py) is a command-line tool for managing Java installations:
# List all detected Java installations
python Modules/updates/java_configurator.py list-java
# List all Minecraft servers from the database
python Modules/updates/java_configurator.py list-servers
# Check Java compatibility for a server
python Modules/updates/java_configurator.py check --server "My Minecraft Server"
# Configure Java for a server (auto-selects if not specified)
python Modules/updates/java_configurator.py configure --server "My Minecraft Server" --java "C:\Program Files\Java\jdk-21\bin\java.exe"