Files
Commonwealth-Online-Public/server
andrewandCursor 7a3e0855b0 Add consumer server CLI with Typer + Rich and Windows launcher
Introduce production-ready CLI for hosting Commonwealth Online servers in
cloud and on-premises environments.

Features:
- Server orchestration service (server_service.py) wrapping relay lifecycle
- JSON configuration system (config.py) for hosted deployments
- Typer+Rich CLI (consumer_server_cli.py) with serve/status/clients/world commands
- Windows launcher (start.bat) for one-click server startup
- Auto-detection of LAN addresses and dependency installation
- Machine-readable JSON output for monitoring and automation

Cli commands:
  serve - Start server with optional config overrides
  status - Display server stats and packet counters
  clients - List connected players
  world time - Set in-game time for all clients
  world weather - Set weather for all clients
  config init - Generate default configuration file

Documentation:
  - Updated docs/setup.md with CLI quick-start guide
  - Added server/README.md with usage instructions
  - Updated changelog and dev-log with test results

Testing: - Verified config generation and loading
  - Verified server startup banner and LAN detection
  - Verified fake client connection and welcome packet
  - Verified CLI help and command routing
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 20:44:40 +12:00
..
2026-05-30 18:13:54 +12:00

Commonwealth Online Server - Quick Start

For Windows Users

Simply double-click start.bat to launch the server:

start.bat

The script will:

  1. Check that Python 3.9+ is installed
  2. Install required dependencies (typer, rich)
  3. Generate a default commonwealth-server.json config file (if needed)
  4. Start the server listening on 0.0.0.0:7777

First Run

On first run, a default commonwealth-server.json file is created in the server directory with these settings:

{
  "host": "0.0.0.0",
  "port": 7777,
  "server_name": "Commonwealth Online Server",
  "max_players": 16,
  "log_verbosity": "info"
}

Customizing the Server

Edit commonwealth-server.json to customize:

  • host: Bind address (default 0.0.0.0 for all interfaces)
  • port: Server port (default 7777)
  • server_name: Display name
  • max_players: Metadata for client displays
  • log_verbosity: debug, info, warning, or error

Connecting Clients

Once the server is running:

  • Local PC: Connect to 127.0.0.1:7777
  • LAN: Connect to your PC's local IP (displayed on startup, e.g., 192.168.1.64:7777)
  • Remote: Forward port 7777/TCP on your router and use your public IP

Stopping the Server

Press Ctrl+C in the terminal to stop the server gracefully.


For Advanced Users (Command Line)

If you prefer command-line usage, use the CLI directly:

cd server
pip install -r requirements.txt

# Generate config
python consumer_server_cli.py config init my-config.json

# Start server
python consumer_server_cli.py serve --config my-config.json

# Check server status (from another terminal)
python consumer_server_cli.py status

# List connected clients
python consumer_server_cli.py clients

# Set in-game time
python consumer_server_cli.py world time 1430

# Set weather
python consumer_server_cli.py world weather 0002b52a

Run python consumer_server_cli.py --help to see all available commands.