Docs / Game Servers / Game Server Auto-Restart with Systemd

Game Server Auto-Restart with Systemd

By Admin · Feb 11, 2026 · Updated Apr 25, 2026 · 7 views · 3 min read

Game Server Auto-Restart with Systemd is a common requirement for VPS administrators. This guide provides practical instructions that you can follow on Ubuntu 22.04/24.04 or Debian 12, though most steps apply to other distributions as well.

Prerequisites

  • A registered domain name (for public-facing services)
  • Sufficient RAM for the game server (check requirements)
  • Root or sudo access to the server
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
  • Basic familiarity with the Linux command line

Server Installation

When scaling this setup, consider vertical scaling (adding more RAM/CPU) first, as it's simpler to implement. Horizontal scaling adds complexity but may be necessary for high-traffic applications.


# Create a dedicated game server user
sudo useradd -m -s /bin/bash gameserver
sudo su - gameserver

# Install SteamCMD
mkdir -p ~/steamcmd && cd ~/steamcmd
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -

# Install the game server
./steamcmd.sh +force_install_dir ~/servers/systemd +login anonymous +app_update 1234567 validate +quit

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

Configuration File Setup

Performance benchmarks show that properly tuned systemd can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.


# Server configuration file
[Server]
ServerName=My systemd Server
MaxPlayers=32
ServerPort=27015
Password=
AdminPassword=changeme
SaveInterval=300

Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.

Firewall and Port Configuration

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.


# Create systemd service for auto-start
sudo tee /etc/systemd/system/systemd.service << 'EOF'
[Unit]
Description=systemd Dedicated Server
After=network.target

[Service]
User=gameserver
WorkingDirectory=/home/gameserver/servers/systemd
ExecStart=/home/gameserver/servers/systemd/start.sh
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable systemd
sudo systemctl start systemd

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Performance Considerations

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.

Performance Optimization

The auto-restart component plays a crucial role in the overall architecture. Understanding how it interacts with systemd will help you make better configuration decisions.


# Create a dedicated game server user
sudo useradd -m -s /bin/bash gameserver
sudo su - gameserver

# Install SteamCMD
mkdir -p ~/steamcmd && cd ~/steamcmd
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -

# Install the game server
./steamcmd.sh +force_install_dir ~/servers/systemd +login anonymous +app_update 1234567 validate +quit

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

  • Use strong, unique passwords for all services
  • Set up fail2ban for brute force protection
  • Keep all software components up to date
  • Enable firewall and allow only necessary ports

Conclusion

This guide covered the essential steps for working with systemd on a VPS environment. For more advanced configurations, refer to the official documentation. Don't hesitate to reach out to our support team if you need help with your specific setup.

Was this article helpful?