Skip to content

Compiling & Running on Linux

The Arctic Fox edited this page Jul 24, 2026 · 3 revisions

Advanced Server — Compiling & Running on Linux

This guide walks through building Advanced Server from source on a Linux server and setting it up as a systemd service that starts automatically on boot. The build process is identical to the Android guide — only the environment setup and deployment differ.

All commands that change system state (creating a user, installing packages, writing service files) require root privileges. Commands run as the disaster user are clearly marked.

Step 1 — Create a dedicated user

Running the server under its own unprivileged user is good practice — it limits what the process can access if something goes wrong.

[root] # useradd -m -d /srv/disaster/ -p '!*' disaster

The flags above create the home directory at /srv/disaster/ automatically (-m -d) and lock password-based login for this account (-p '!*'), so it can only be accessed via su or the service itself.

Step 2 — Install Rust, Git, and Screen

Install the required packages using your distribution's package manager. git is needed to clone the repository in the next step; screen is needed to run the server as a background service later.

Debian / Ubuntu

[root] # apt install -y rustc cargo git screen

Fedora / RHEL

[root] # dnf install -y rust cargo git screen

Arch Linux

[root] # pacman -S --noconfirm rust git screen

The Rust version shipped by some distro repositories can be outdated. If cargo build fails with a toolchain version error, install Rust via rustup instead.

Step 3 — Clone the repository

Switch into that user's session to do everything that follows:

[root] # su - disaster

As the disaster user, clone the source and enter the directory:

[disaster] $ git clone https://github.com/thearcticfox25/AdvancedServer.git
[disaster] $ cd AdvancedServer

Step 4 — Build in release mode

[disaster] $ cargo build --release

Cargo downloads and compiles all dependencies. The compiler will emit several warnings — this is expected. The finished binary appears at target/release/AdvancedServer.

Step 5 — Set up the instance directory

The systemd service expects the binary and all server data to live in /srv/disaster/ — which was already created and owned by the disaster user in step 1. Just copy the binary in:

[disaster] $ cp ~/AdvancedServer/target/release/AdvancedServer /srv/disaster/

On first launch the server generates a default config.toml in the working directory. Edit it before enabling the service — see the Config Reference for all available options.

Step 6 — Create the systemd service

End the disaster user's session to be able to make further changes:

[disaster] $ exit

The service uses GNU Screen to keep the server's interactive CLI accessible even when running as a background daemon. Save the following to /etc/systemd/system/td2d-server.service:

[Unit]
Description=Sonic.EXE: TD2DR Server
After=network.target

[Service]
Type=forking
User=disaster
WorkingDirectory=/srv/disaster/
ExecStart=/usr/bin/screen -dmS td2d /srv/disaster/AdvancedServer
ExecStop=/usr/bin/screen -S td2d -X stuff "?halt^M"
Restart=on-failure

[Install]
WantedBy=multi-user.target

ExecStop sends the ?halt command to the server's stdin via screen, allowing it to shut down gracefully rather than being killed outright. The ^M at the end is a carriage return (Enter key).

Reload systemd, enable the service to start on boot, and start it now:

[root] # systemctl daemon-reload
[root] # systemctl enable --now td2d-server

Check that it came up cleanly:

[root] # systemctl status td2d-server

Step 7 — Attaching to the server console

Because the server runs inside a screen session, you can attach to its interactive console at any time:

[root] # su - disaster
[disaster] $ screen -r td2d

Detach without stopping the server with Ctrl+A then Ctrl+D (hold Ctrl, press A, then release A and press D — without releasing Ctrl).

Step 8 — Connect from the game

Open Sonic.exe — The Disaster 2D Remake, go to Join Game, and enter the server's IP address. Use localhost if the game is running on the same machine.