Repository navigation
Adding A Game Server
This page is for two audiences:
- Operators and new contributors who want the short path: copy a similar game, keep the same commands, and land a working lifecycle.
- Module authors who need the exact AlphaGSM contract, tests, and docs.
You do not add a game by editing a config file. Each game is a module: a
Python package under src/gamemodules/<name>/ that AlphaGSM loads by name.
create → setup → start → status / query / info → stop
That is the same operator flow as Minecraft, TF2, Palworld, and HL2DM. A new module is incomplete until it participates in that flow.
| If the dedicated server is… | Start from | Why |
|---|---|---|
| A Linux SteamCMD app with its own layout | [[Palworld | Palworld]] (src/gamemodules/palworld/) |
Source / GoldSrc with srcds_run
|
[[HL2DM | Hl2dmserver]] (src/gamemodules/hl2dmserver/) |
| A Java jar | [[Minecraft Vanilla | Minecraft-Vanilla]] (src/gamemodules/minecraft/vanilla.py) |
| Another Valve game |
src/utils/valve_server.py via define_valve_server_module()
|
Shared Source/GoldSrc defaults |
Copy the closest module. Do not invent a new command language.
When the module is done, this should work with the same commands users already know:
./alphagsm myserver create <module_id>
./alphagsm myserver setup
./alphagsm myserver start
./alphagsm myserver status
./alphagsm myserver query
./alphagsm myserver info
./alphagsm myserver info --json
./alphagsm myserver stopIf setup needs a port and install directory, the smoke tests pass them
non-interactively (-n, port, directory). Match that.
Canonical top-level games are packages:
src/gamemodules/<module_id>/
__init__.py # public import surface
main.py # lifecycle implementation
curated_mods.json # only if this game has its own checked-in mods
Keep the module id stable. import_module("gamemodules.<module_id>") is what
create uses. Aliases belong in src/server/module_aliases.json, not extra
wrapper files.
Flat .py helpers are fine inside an existing family (minecraft/paper.py).
Do not add a new top-level src/gamemodules/mygame.py.
Required hooks (every module):
| Hook | Backs |
|---|---|
configure(server, ask, *args, **kwargs) |
setup — store at least port and dir, init backup, return (args, kwargs) for install
|
install(server, *args, **kwargs) |
setup — download/copy files, write initial config |
get_start_command(server, *args, **kwargs) |
start — return (argv_list, working_dir)
|
do_stop(server, time, *args, **kwargs) |
stop |
status, message, backup, checkvalue
|
matching commands |
get_runtime_requirements(server) |
runtime / Docker metadata |
get_container_spec(server) |
Docker launch spec |
Also export commands, command_args, command_descriptions, and
command_functions (use () / {} when you have no extra commands).
Always add get_info_address(server) unless you use
define_valve_server_module(), which sets it. Add get_query_address when
the query port or protocol is not default A2S on the game port.
If set keys map to the game's own config file, add sync_server_config(server)
and list those keys in config_sync_keys. Do not put AlphaGSM-only keys
(backup, image, runtime metadata) in that list.
New modules should set:
module_contract_version = 1That opts the public import surface into structural validation before runtime-hook inference. It proves hooks exist and are callable. It does not prove the server starts, downloads, or authenticates.
The full hook specification is in src/server/gamemodules.py and DEVELOPERS.md.
Ownership:
| Owner | Does |
|---|---|
Manager (Server) |
Command order, ports, datastore, runtime choice, errors |
| Shared operation | One action: SteamCMD download, a config rewrite, a runtime spec |
| Family builder | Defaults proven across an engine family |
| Game module | Order the operations, validate game values, handle exceptions |
Reuse a helper only when success and failure behaviour match. Palworld
calls installers.download_steamcmd(...) then prepares PalWorldSettings.ini
itself. HL2DM keeps define_valve_server_module() and declares
RUNTIME_FAMILY / PORT_DEFINITIONS once for both Docker wrappers.
Do not add a base-class hierarchy, mixin system, or game-name switches inside shared helpers.
Choose a runtime family first:
javaquake-linuxservice-consolesimple-tcpsteamcmd-linux-
wine-proton(Windows-only on Linux)
Then write explicit module-scope wrappers:
import server.runtime as runtime_module
def get_runtime_requirements(server):
return runtime_module.build_runtime_requirements(
server,
family="steamcmd-linux",
port_definitions=PORT_DEFINITIONS,
)
def get_container_spec(server):
return runtime_module.build_container_spec(
server,
family="steamcmd-linux",
get_start_command=get_start_command,
port_definitions=PORT_DEFINITIONS,
)Keep get_start_command working for the host/process path as well.
A new module is not done until all of these exist:
-
Unit tests under
tests/unit_tests/for module behaviour or hooks. -
One integration test at
tests/integration_tests/test_<module>.pythat drives AlphaGSM commands — not the game binary directly:create,setup,start, readiness,status,query,info,info --json,stop, shutdown. -
A smoke runner at
tests/smoke_tests/run_<module>.shshowing the same real-world order.
For Source servers, hibernation is not a pass. The test must keep the server
awake enough that real A2S query / info succeed.
If the module is container-capable, prove the Docker path as well as process.
Quality gates:
make lint # must score 10.00/10
make test
# integration/smoke in CI or with ALPHAGSM_WORK_DIR set; do not disable a
# server to hide a timeout- Add
docs/servers/<module_id>.mdwith copy-paste create/setup/start/stop. - Link it from docs/README.md.
- Add a changelog entry.
- When integration actually passes, mark the server in TEST_STATUS.md and regenerate game-server-support.md. Do not promote support status from structural validation alone.
PASSED means the lifecycle self-provisions in CI.
ENABLED (AUTH) means provider credentials/tokens/licenses are still required.
ENABLED (BYO) means the operator must supply owned files, staged game assets, or URLs.
- Package under
src/gamemodules/<module_id>/with__init__.py+main.py - Required hooks and command tables exported on the public surface
-
module_contract_version = 1 - Explicit
get_runtime_requirements/get_container_spec -
get_info_address(andget_query_addressif needed) - Config sync only for real game-config keys
- Unit test + AlphaGSM integration test + smoke runner
- Server guide, changelog, tracker update when the lifecycle is proven