Gamer-Server-Utility-Scripts/Factorio
2025-07-29 13:59:17 -04:00
..
control.lua Add Factorio/control.lua 2024-11-29 20:23:25 -05:00
factcheck.sh Update Factorio/factcheck.sh 2025-07-29 13:59:17 -04:00
mod_updater.py Add Factorio/mod_updater.py 2024-03-06 19:40:20 -05:00
README.md Update Factorio/README.md 2025-07-29 13:57:36 -04:00
screenstart.sh New version 2025-07-29 13:55:36 -04:00
servers-config.ini Add Factorio/servers-config.ini 2025-07-29 13:57:02 -04:00

Factorio Multi-Server Manager

This project provides a robust, automated solution for managing multiple Factorio headless servers on Linux. It includes scripts for updating Factorio, orchestrating server processes, monitoring server health, and sending notifications—all driven by a single configuration file.


Features

  • Automatic Update Checks: Detects and installs new Factorio releases.
  • Multi-Server Management: Start, stop, and restart multiple servers as defined in a single INI config.
  • Screen Integration: Each server runs in its own screen session for easy process management and detachment.
  • Health Monitoring: Detects and restarts crashed or missing servers.
  • Discord Notifications: Sends update notifications to a Discord webhook.
  • Colorful, Informative Output: Terminal output is styled for clarity and quick status checks.
  • Graceful Shutdowns: Ensures servers save and shut down cleanly before updates or restarts.
  • Mod Support: Handles mod directory and mod settings propagation.

Directory Structure

/home/factorio/
  ├── factcheck.sh              # Main health check and update script
  ├── new_screen_start.sh       # Server start/stop/update orchestrator
  ├── servers-config.ini        # INI file listing all managed servers
  ├── factorio/                 # Factorio installation directory
  ├── mods/
  │    └── default/             # Default mod directory for servers
  └── servers/
       ├── server1/
       ├── server2/
       └── ...                  # One directory per server, each with its own config and saves

Setup & Reproduction

1. Dependencies

Install dependencies (example for Ubuntu):

sudo apt update
sudo apt install screen jq curl wget

2. Directory Preparation

  • Place all scripts in /home/factorio/
  • Place the Factorio headless server in /home/factorio/factorio/
  • Each server should have its own directory under /home/factorio/servers/
  • Mods should be in /home/factorio/mods/default/
  • Ensure all scripts are executable:
    chmod +x /home/factorio/factcheck.sh /home/factorio/new_screen_start.sh
    

3. Configuration

Edit servers-config.ini to define your servers. Example:

[test]
port=34198
settings=/home/factorio/servers/test/server-settings.json
config=/home/factorio/servers/test/config.ini
mod_directory=/home/factorio/mods/default
use_whitelist=false

[private]
port=55557
settings=/home/factorio/servers/private/server-settings.json
config=/home/factorio/servers/private/config.ini
mod_directory=/home/factorio/mods/default
use_whitelist=true
  • Comment out any server blocks you do not want managed by prefixing with ;.

Usage

Health Check, Update, and Auto-Restart

Run the main script to check for updates, ensure all servers are running, and restart any that are down:

./factcheck.sh

Manual Server Management

  • Start/Restart All Servers:

    ./new_screen_start.sh
    

    (Stops and starts each server sequentially.)

  • Stop All Servers:

    ./new_screen_start.sh --stop
    
  • Update Factorio and Mods:

    ./new_screen_start.sh --update
    

    (Stops all servers, updates Factorio if needed, then restarts all servers.)

  • Help:

    ./new_screen_start.sh --help
    

Tips & Best Practices

  • Automate Health Checks: Add factcheck.sh to a cron job for regular health checks and updates. Example (runs every 15 minutes):

    */15 * * * * /home/factorio/factcheck.sh >> /home/factorio/factcheck.log 2>&1
    
  • Discord Webhook: The update script sends notifications to a Discord webhook. Change the webhook URL in factcheck.sh to your own server if desired.

  • Logs: Server logs are monitored for readiness and clean shutdowns. Check /home/factorio/servers/<server>/factorio-current.log for details.

  • Screen Sessions: Each server runs in a named screen session. Use screen -ls to list sessions and screen -r <session> to attach.

  • Mod Management: Place shared mods in /home/factorio/mods/default/. The scripts will propagate mod settings as needed.


Troubleshooting

  • Server Not Starting: Check that the Factorio binary is present and executable at /home/factorio/factorio/bin/x64/factorio.
  • Permissions: Ensure the factorio user has ownership and execute permissions for all relevant files and directories.
  • Config Errors: Double-check paths in servers-config.ini for typos or missing files.

License

MIT License (or specify your own)


Credits

Created by ClayGarth.com and contributors. Inspired by the Factorio community and designed for reliability and ease of use.