A complete solution for running and managing multiple Factorio headless server instances on Linux with systemd. The project consists of two main components:
- Launcher - A bash script and systemd service template that automatically downloads Factorio, installs mods from
mod-list.json, and runs headless servers - Webapp - A Go-based web application for managing multiple Factorio server instances with a modern UI
- Automatic Factorio Installation: Downloads and installs the specified Factorio version automatically
- Mod Auto-Download: Parses
mod-list.jsonand downloads enabled mods from the Factorio mod portal - Systemd Integration: Template service file for easy instance management
- Version Management: Supports specific versions or "latest" to always run the newest stable release
- Configuration Templates: Pre-configured server settings and config files with variable substitution
- Instance Dashboard: View all Factorio instances with real-time status indicators
- Service Control: Start, stop, restart, enable/disable autostart for any instance
- File Upload: Drag-and-drop upload for mod-list.json, mod-settings.dat, and save files
- Save Backup: Manual backup and restore of save files
- Log Viewer: Real-time log streaming via Server-Sent Events
- Instance Creation: Create new instances with customizable settings
- Linux system with systemd
- Factorio.com account credentials (for mod downloads and public server visibility)
- Go 1.21+ (for building the webapp and moddownloader)
- Root access for initial installation only (services run as non-root user)
-
Clone the repository:
git clone https://github.com/draxxris/factorio-daemon cd factorio-daemon -
Install the launcher:
cd launcher sudo make installThis will:
- Create a system user
factoriowith home directory/opt/factorio - Install the launcher scripts and templates
- Set proper ownership and permissions
- Create a system user
-
Configure credentials:
cd /opt/factorio # Create .env with your Factorio credentials echo 'export FACTORIO_USERNAME=your_username' | sudo tee .env echo 'export FACTORIO_TOKEN=your_token' | sudo tee -a .env sudo chown factorio:factorio .env sudo chmod 640 .env
-
Create an instance:
# Copy the example environment file sudo cp env-example env-myserver # Edit the instance configuration sudo vi env-myserver sudo chown factorio:factorio env-myserver sudo chmod 640 env-myserver
Instance configuration (
env-myserver):NAME=myserver VERSION=latest TITLE="[quality=rare] My Server" DESCRIPTION="Welcome to my server." PORT=34197 NON_BLOCKING_SAVE=true -
Start your instance:
sudo systemctl daemon-reload sudo systemctl start factorio@myserver sudo systemctl enable factorio@myserver
cd webapp
make build
sudo make install install-sudoers
sudo systemctl daemon-reload
sudo systemctl enable --now factorio-webappAccess the webapp at http://your-server:8080
Note: All services run as the factorio user for security. The webapp uses sudo to manage factorio@* systemd services without requiring a password.
For production use, it's recommended to run nginx as a reverse proxy with basic authentication:
cd webapp
sudo make nginx-setupYou will be prompted to enter a username and password for accessing the webapp.
This setup:
- Configures nginx as a reverse proxy to the webapp
- Enables basic HTTP authentication
- Sets a 100MB upload limit for save files and mods
- Configures proper timeouts for long-running operations
After setup, access the webapp at http://your-server:8090/ instead of port 8080.
Prerequisites:
- nginx must be installed
htpasswdtool required (installapache2-utilson Debian/Ubuntu orhttpd-toolson RHEL/CentOS)
To remove the nginx configuration:
sudo rm /etc/nginx/conf.d/factorio.conf /etc/nginx/.htpasswd-factorio
sudo systemctl reload nginxThe easiest way to set up a modpack is to use the Factorio client:
- Install and configure your mods in the Factorio client
- Locate your
mod-list.jsonandmod-settings.datfrom the Factorio mods directory (%APPDATA%\Factorio\mods) - Upload these files via the webapp to your instance's staging area
- Deploy the files - the launcher will automatically download all enabled mods
- Open http://your-server:8090/ in your browser
- Click on an instance card to manage it
- Upload files via drag-and-drop or click
- Stop the instance before deploying files
- Click "Deploy Files" to move staged files to the instance directory
- Start the instance - factorio.sh will move files to proper locations
The webapp provides a clean interface for:
- Viewing Instances: See all instances with their current status (running, stopped, etc.)
- Controlling Services: Start, stop, restart, enable, or disable instances
- Uploading Files: Drag and drop
mod-list.json,mod-settings.dat, or save files - Deploying Files: Move staged files to the instance directory
- Viewing Logs: Stream real-time logs from any instance
- Backup/Restore: Create backups of save files and restore them later
- Upload files to staging area
- Stop the instance (required)
- Click "Deploy Files" - files are moved to
/opt/factorio/{instance}/ - Start the instance
factorio.shmoves files to proper locations:mod-list.json→mods/mod-list.jsonmod-settings.dat→mods/mod-settings.datmain.zip→saves/main.zip
# Start an instance
sudo systemctl start factorio@myserver
# Stop an instance
sudo systemctl stop factorio@myserver
# Restart an instance
sudo systemctl restart factorio@myserver
# Enable autostart
sudo systemctl enable factorio@myserver
# Disable autostart
sudo systemctl disable factorio@myserver
# View logs
sudo journalctl -u factorio@myserver -fNote: Services run as the factorio user. Use sudo for systemctl commands as they require root to manage systemd services.
Each instance has an env-{name} file with the following variables:
| Variable | Required | Default | Description |
|---|---|---|---|
NAME |
Yes | - | Instance name (used for directory and systemd service) |
VERSION |
Yes | - | Factorio version or "latest" for newest stable |
TITLE |
No | "Factorio Server" | Server display name |
DESCRIPTION |
No | - | Server description |
PORT |
No | 34197 | Game port |
NON_BLOCKING_SAVE |
No | true | Enable non-blocking save |
These are typically pulled from the systemd unit file:
| Variable | Default | Description |
|---|---|---|
SERVER_PORT |
8080 | HTTP server port |
SERVER_HOST |
0.0.0.0 | HTTP server host |
FACTORIO_BASE_DIR |
/opt/factorio | Base directory for Factorio |
STAGING_DIR |
/opt/factorio/webapp/data/staging | Staging directory for uploads |
BACKUP_DIR |
/opt/factorio/webapp/data/backups | Backup directory for saves |
LOG_POLL_INTERVAL |
2 | Log polling interval in seconds |
LOG_MAX_LINES |
1000 | Maximum log lines to retrieve |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/instances |
List all instances with status |
| GET | /api/instances/:name |
Get instance details |
| POST | /api/instances |
Create new instance |
| DELETE | /api/instances/:name |
Delete instance |
| POST | /api/instances/:name/start |
Start service |
| POST | /api/instances/:name/stop |
Stop service |
| POST | /api/instances/:name/restart |
Restart service |
| POST | /api/instances/:name/enable |
Enable autostart |
| POST | /api/instances/:name/disable |
Disable autostart |
| GET | /api/instances/:name/logs |
Get recent logs |
| GET | /api/instances/:name/logs/stream |
Stream logs via SSE |
| POST | /api/instances/:name/upload |
Upload files to staging |
| GET | /api/instances/:name/staged |
List staged files |
| DELETE | /api/instances/:name/staged |
Clear staged files |
| POST | /api/instances/:name/deploy |
Deploy staged files |
| POST | /api/instances/:name/backup |
Backup save file |
| GET | /api/instances/:name/backups |
List backups |
| POST | /api/instances/:name/backups/:filename/restore |
Restore backup |
The Factorio daemon includes built-in RCON support for interacting with running Factorio servers.
RCON is automatically enabled for all instances. When an instance starts for the first time:
- A random port is assigned for RCON communication
- A random password is generated for authentication
- Credentials are stored in the instance directory:
rcon-port- Contains the RCON port numberrcon-passwd- Contains the RCON password
These credentials persist across server restarts, so you only need to retrieve them once.
- RCON binds to
127.0.0.1only, meaning it's only accessible from the local machine - For remote access, set up an SSH tunnel or use a reverse proxy
- RCON is only available when the Factorio server is running
The webapp provides a convenient RCON interface through the instance modal:
-
Access RCON: Click on an instance card, then navigate to the RCON tab in the modal
-
Server Time: Displays the current in-game time on the server
-
Player List: Shows all currently connected players with their names and online status
-
Add Admin: Add new administrators to the server using their Factorio username
To get the RCON credentials for scripting or external tools:
# Read the RCON port
cat /opt/factorio/{instance}/rcon-port
# Read the RCON password
cat /opt/factorio/{instance}/rcon-passwdAGPL v3 License - See LICENSE.txt file for details