# Agrarian Dedicated Server Build Runbook

Agrarian's multiplayer server target is Linux. Windows-Builder remains the
interactive Unreal build machine, but the server artifact should run on an
Ubuntu cloud VM or other Linux host.

## Public Endpoint Convention

Use this MVP gameplay endpoint unless a later deployment requires a different
host name:

- DNS name: `play.agrariangame.com`
- Unreal gameplay traffic: `7777/udp`
- SSH: admin IPs only

When the first Ubuntu gameplay VM is created, point the `play` A/AAAA record at
that VM. Do not point this name at the tile server; tile delivery and gameplay
should remain separate until a deliberate combined-host decision is made.

## Build Machine

Use Windows-Builder for the first repeatable build lane:

- Unreal Engine `5.7`
- VS 2022 Build Tools toolchain compatible with Unreal `5.7`
- Epic Linux cross-compile toolchain for Unreal `5.7`
- Project path: `P:\AgrarianGameBulid` when mapped from `\\DevBox\projects`

The server target is `AgrarianGameServer`, defined in
`Source/AgrarianGameServer.Target.cs`.

## Ubuntu Host Bootstrap

Prepare a new Ubuntu gameplay host with:

```bash
sudo Operations/cloud-game-server/bootstrap_ubuntu_game_server.sh play.agrariangame.com
```

The script installs baseline packages, creates an `agrarian` service user,
creates `/opt/agrarian/server`, writes a systemd unit named
`agrarian-game-server`, and opens `7777/udp` with `ufw` when available.

For DigitalOcean or another cloud provider later, create an Ubuntu LTS droplet
or VM, copy this repository or just the script onto the host, run the bootstrap
script, then copy the `Builds/LinuxServerDevelopment` package contents into
`/opt/agrarian/server`.

## Build Command

From an elevated or normal Command Prompt on Windows-Builder:

```bat
cd /d P:\AgrarianGameBulid
Scripts\BuildLinuxDedicatedServer-Windows.bat
```

Expected output:

- Logs: `Saved\BuildLogs\BuildLinuxDedicatedServer.log`
- Archive: `Builds\LinuxServerDevelopment`

If the script fails before compile with a Linux toolchain error, install Epic's
Unreal `5.7` Linux cross-compile toolchain on Windows-Builder, reopen the
terminal, and run the script again.

## Initial Runtime Shape

The first server package cooks the Ground Zero MVP map:

```text
/Game/Agrarian/Maps/L_GroundZeroTerrain_Test
```

First cloud/server launch target:

```bash
./AgrarianGameServer L_GroundZeroTerrain_Test?listen -log -port=7777
```

In-game/admin MVP travel command:

```text
AgrarianServerTravel GroundZero
```

This command is allowlisted to the Ground Zero MVP map and should remain the
only server travel path until tile/session validation is stronger.

Systemd launch target created by the bootstrap script:

```bash
sudo systemctl restart agrarian-game-server
sudo journalctl -u agrarian-game-server -f
```

Open firewall ports only as needed:

- `7777/udp` for Unreal gameplay traffic.
- SSH from trusted admin IPs only.

Do not expose editor, SMB, RDP, database, or admin ports on the public server.

## Smoke Test

For the first MVP validation:

1. Build the Linux server package on Windows-Builder.
2. Copy the archived server package to an Ubuntu test VM.
3. Start the server with `-log -port=7777`.
4. Confirm the log reaches map load without fatal errors.
5. Connect from a packaged Windows Development client on the LAN or test VPN.
6. Record the commit, package date, map, client build, and server log path.

## Current Limits

This runbook creates the repeatable build lane. It does not yet prove a full
external multiplayer session. That remains a later roadmap item after the
project has a clean server package and a stable deploy target.
