My Factorio Info: Difference between revisions

From GotOpinion
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Factorio Headless Setup ==
== Factorio Headless Setup ==
Updated 2025/07/17
'''These steps were done with Ubuntu 22.04.5 LTS'''


Resources:
Resources:
Line 5: Line 9:
* Stable [https://factorio.com/get-download/stable/headless/linux64 Factorio headless] server
* Stable [https://factorio.com/get-download/stable/headless/linux64 Factorio headless] server


Check that your version of glibc is >= 2.18.
Check that your version of glibc is >= 2.18 using <code>ldd --version</code>


<pre>robot01@apu01:~$ ldd --version
<pre>$ ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu10) 2.23
ldd (Ubuntu GLIBC 2.35-0ubuntu3.7) 2.35
Copyright (C) 2016 Free Software Foundation, Inc.
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Line 16: Line 20:
Output of ldd command confirms glibc version >2.18.
Output of ldd command confirms glibc version >2.18.


Switch to <code>$ cd /opt</code> directory and download latest Factorio stable headless version (1.1.87 as of this writing)
Switch to <code>$ cd /opt</code> directory and download latest Factorio stable headless version (2.0.60 as of this writing)
 
<pre>$ sudo wget https://factorio.com/get-download/stable/headless/linux64
--2023-09-04 14:28:09--  https://factorio.com/get-download/stable/headless/linux64
Resolving factorio.com (factorio.com)... 2606:4700:20::681a:f58, 2606:4700:20::ac43:47c5, 2606:4700:20::681a:e58, ...
Connecting to factorio.com (factorio.com)|2606:4700:20::681a:f58|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.factorio.com/releases/factorio_headless_x64_1.1.87.tar.xz?secure=4g154TPABPYOpo7oo2Cnvw,1693859289 [following]
--2023-09-04 14:28:09--  https://dl.factorio.com/releases/factorio_headless_x64_1.1.87.tar.xz?secure=4g154TPABPYOpo7oo2Cnvw,1693859289
Resolving dl.factorio.com (dl.factorio.com)... 2a02:6ea0:d800::2, 212.102.46.8
Connecting to dl.factorio.com (dl.factorio.com)|2a02:6ea0:d800::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58853524 (56M) [application/octet-stream]
Saving to: ‘linux64’
 
linux64                          100%[==========================================================>]  56.13M  32.9MB/s    in 1.7s   


2023-09-04 14:28:11 (32.9 MB/s) - ‘linux64’ saved [58853524/58853524]</pre>
<pre>$ sudo wget https://factorio.com/get-download/stable/headless/linux64</pre>


Rename file to match version (1.1.87 in this example)
Rename file to match version (2.0.60 in this example)
<pre>$ sudo mv linux64 factorio_headless_x64_1.1.87.tar.xz</pre>
<pre>$ sudo mv linux64 factorio-headless_linux_2.0.60.tar.xz</pre>


Extract archived and zipped file
Extract archived and zipped file
<pre>$ sudo tar -xJf factorio_headless_x64_1.1.87.tar.xz
<pre>$ sudo tar -xJf factorio-headless_linux_2.0.60.tar.xz  
$ ls -l
anon@ox:/opt$ ls -l
total 57480
total 55376
drwxr-xr-x 8 steamy steamy     4096 Sep  4 14:32 factorio
drwxr-xr-x 8 factorio factorio     4096 Jul 18 05:05 factorio
-rw-r--r-- 1 root   root   58853524 Jul 4 05:36 factorio_headless_x64_1.1.87.tar.xz</pre>
-rw-r--r-- 1 root     root     56693436 Jul 10 10:05 factorio-headless_linux_2.0.60.tar.xz</pre>


Remove file (save space, you can always download the file again, if needed)
Remove file (save space, you can always download the file again, if needed) using <code>sudo rm <filename.tar.xz></code>
<pre>robot01@apu01:/opt$ sudo rm factorio_headless_x64_1.1.87.tar.xz</pre>


Add a new user to run factorio and assign ownership of <code>/opt/factorio</code> directory to same user
Add a new user to run factorio and assign ownership of <code>/opt/factorio</code> directory to same user
Line 53: Line 41:




Verify permissions show factorio for both user and group
Verify permissions show factorio for both user and group with <code>ls -ld /opt/factorio</code>
<pre>$ ls -l /opt/factorio</pre>
<pre>$ ls -ld /opt/factorio/
drwxr-xr-x 4 factorio factorio 4096 May  4 17:07 /opt/factorio/</pre>




Line 66: Line 55:


Start server and look for something like "File /savename does not exist."
Start server and look for something like "File /savename does not exist."
<pre>$ /opt/factorio/bin/x64/factorio --start-server savename
<pre>$ /opt/factorio/bin/x64/factorio --start-server savename.zip</pre>
  0.000 2018-05-01 21:20:47; Factorio 0.16.36 (build 36253, linux64, headless)
  0.260 Operating system: Linux (Ubuntu 16.04)
  0.260 Program arguments: "/opt/factorio/bin/x64/factorio" "--start-server" "savename"
  0.260 Read data path: /opt/factorio/data
  0.260 Write data path: /opt/factorio [103696/111098MB]
  0.260 Binaries path: /opt/factorio/bin
  0.304 System info: [CPU: AMD G-T40E Processor, 2 cores, RAM: 3550 MB]
  0.304 Environment: DISPLAY=<unset>, WAYLAND_DISPLAY=<unset>
  0.305 Running in headless mode
  0.316 Error GlobalModSettings.cpp:107: Failed to migrate mod settings file: Error when opening /opt/factorio/mods/mod-settings.json for reading: No such file or directory
  0.322 Loading mod core 0.0.0 (data.lua)
  0.388 Loading mod base 0.16.36 (data.lua)
  1.063 Loading mod base 0.16.36 (data-updates.lua)
  1.313 Checksum for core: 1316978547
  1.313 Checksum of base: 4140083139
  2.006 Info PlayerData.cpp:67: Local player-data.json unavailable
  2.006 Info PlayerData.cpp:72: Cloud player-data.json unavailable
  2.012 Custom inputs active: 0
  2.015 Factorio initialised
  2.016 Info ServerSynchronizer.cpp:29: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
  2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(Ready) to(PreparedToHostGame)
  2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(PreparedToHostGame) to(CreatingGame)
  2.017 Loading map /savename
  2.017 Error ServerMultiplayerManager.cpp:96: MultiplayerManager failed: "File /savename does not exist."
  2.017 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(CreatingGame) to(InitializationFailed)
  2.017 Info GlobalContext.cpp:694: Waiting for child processes to exit:
  2.020 Info ServerMultiplayerManager.cpp:142: Quitting multiplayer connection.
  2.020 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(InitializationFailed) to(Closed)
  2.062 Info UDPSocket.cpp:206: Closing socket
  2.065 Goodbye</pre>


At this point you can load up saved games or create some games. Before that, I want to install Factorio init script
At this point you can load up saved games or create some games. I find it easier to create new game in Factorio client, save it, then SFTP the saved file to my headless server save directory.


Exit from factorio user back to sudo account
=== Update for 2.0.60 ===
<pre>$ exit
logout</pre>


Switch to <code>/opt</code> directory
With a base client and headless server (i.e., no mods) installation, I encountered a mod mismatch error when attempting to connect with the client. To fix this, I had to edit the default "true" values to "false" in /opt/factorio/mods/mod-list.json file for "elevated-rails", "quality", and "space-age".
<pre>$ cd /opt</pre>


I had to install git on my Ubuntu system
Here is my mod-list.json modified file:
<pre>$ sudo apt install git</pre>


Clone Factorio init script from github
<pre>$ cat factorio/mods/mod-list.json 
<pre>$ sudo git clone https://github.com/Bisa/factorio-init.git
Cloning into 'factorio-init'...
remote: Enumerating objects: 1028, done.
remote: Counting objects: 100% (145/145), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 1028 (delta 70), reused 121 (delta 60), pack-reused 883
Receiving objects: 100% (1028/1028), 265.92 KiB | 2.95 MiB/s, done.
Resolving deltas: 100% (584/584), done.
anon@steamnuc00:/opt$ git --version
git version 2.25.1</pre>


Validate factorio-init directory exists
{
<pre>$ ls -l /opt
  "mods":
drwxr-xr-x 8 steamy steamy     4096 Sep  4 14:53 factorio
  [
drwxr-xr-x 5 root  root       4096 Sep  4 15:00 factorio-init</pre>
   
    {
      "name": "base",
      "enabled": true
    },
   
    {
      "name": "elevated-rails",
      "enabled": false
    },
   
     {
      "name": "quality",
      "enabled": false
    },
   
    {
      "name": "space-age",
       "enabled": false
    }
  ]
}</pre>


Change ownership to Factorio user
== Publish game on Factorio matching server ==


<pre>$ sudo chown -R steamy:steamy /opt/factorio-init/</pre>
Copy /opt/factorio/data/server-settings.example.json to /opt/factorio/data/server-settings.json.


Edit config.example and add your Factorio users.
<pre>$ sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json</pre>


<pre>$ sudo vi /opt/factorio-init/config.example</pre>
Edit appropriate server-settings.json values.


Here are my edits to config.example after making edits
I used _comment_token versus password value. The appropriate value is located in %appdata%\Factorio\player-data.json under the key name "service-token". The service-token is populated after you've browsed the multiplayer servers via your Factorio game client.
<pre>$ grep -i steamy factorio-init/config.example                 
USERNAME=steamy
USERGROUP=steamy</pre>


Edit factorio.service.example with your default values
My player-data.json for user "anon" on Windows was located at C:\Users\anon\AppData\Roaming\Factorio.
 
<pre>$ sudo vi /opt/factorio-init/extras/factorio.service.example</pre>
 
Here are my edits to factorio.service.example after making edits
 
<pre>$ grep -i steamy /opt/factorio-init/extras/factorio.service.example
User=steamy
Group=steamy</pre>
 
Make Factorio start on operating system boot and restart if failure (configurable - I kept defaults for now)
<pre>$ sudo cp /opt/factorio-init/extras/factorio.service.example /etc/systemd/system/factorio.service
$ sudo systemctl daemon-reload</pre>
 
Sysvinit
<pre>$ sudo ln -s /opt/factorio-init/factorio /etc/init.d/factorio
$ sudo chmod +x /opt/factorio-init/factorio</pre>
 
Show help
<pre>$ service factorio help
Usage: /etc/init.d/factorio COMMAND
 
Available commands:
  start                                                  Starts the server
  stop                                                  Stops the server
  restart                                                Restarts the server
  status                                                Displays server status
  players-online                                        Shows online players
  players                                                Shows all players
  cmd [command/message]                                  Open interactive commandline or send a single command to the server
  log [--tail|-t]                                        Print the full server log, optionally tail the log to follow in real time
  chatlog [--tail|-t]                                    Print the current chatlog, optionally tail the log to follow in real time
  new-game name [map-gen-settings] [map-settings]        Stops the server and creates a new game with the specified
                                                        name using the specified map gen settings and map settings json files
  save-game name                                        Stops the server and saves game to specified save
  load-save name                                        Stops the server and loads the specified save
  install [tarball]                                      Installs the server with optional specified tarball
                                                        (omit to download and use the latest headless server from Wube)
  update [--dry-run]                                    Updates the server
  invocation                                            Outputs the invocation for debugging purpose
  listcommands                                          List all init-commands
  listsaves                                              List all saves
  version                                                Prints the binary version
  mod                                                    Manage mods (see /etc/init.d/factorio mod help for more information)
  help                                                  Shows this help message</pre>
 
Setup Autocompletion
<pre>$ sudo ln -s /opt/factorio-init/extras/bash_autocomplete /etc/bash_completion.d/factorio
$ sudo ln -s /opt/factorio-init/factorio /usr/local/bin/factorio</pre>
 
Copy example server settings (make any changes you want to copy)
<pre>$ sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json</pre>
 
Copy example configuration (make any changes you want to copy)
<pre>$ sudo cp /opt/factorio-init/config.example /opt/factorio-init/config</pre>


Make any changes to config ini
Make any changes to config ini
<pre>robot01@apu01:/opt/factorio$ sudo vi /opt/factorio/config/config.ini</pre>
<pre>robot01@apu01:/opt/factorio$ sudo vi /opt/factorio/config/config.ini</pre>


=== Update headless server ===
== Updating Factorio headless server ==
 
download latest headless version
 
unzip and untar
 
<pre>sudo tar -xJf linux64</pre>
 
change permissions to your dedicated factorio user
 
<pre>sudo chown -R steamy:steamy factorio</pre>


launch game
# Download the latest copy of the headless server using the steps above.
# Move and rename the headless server following the steps above.
# Assign ownership of <code>/opt/factorio</code> directory to factorio user used above.


[[Gaming]]
[[Gaming]]

Latest revision as of 00:24, 18 July 2025

Factorio Headless Setup

Updated 2025/07/17

These steps were done with Ubuntu 22.04.5 LTS

Resources:

Check that your version of glibc is >= 2.18 using ldd --version

$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.7) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Output of ldd command confirms glibc version >2.18.

Switch to $ cd /opt directory and download latest Factorio stable headless version (2.0.60 as of this writing)

$ sudo wget https://factorio.com/get-download/stable/headless/linux64

Rename file to match version (2.0.60 in this example)

$ sudo mv linux64 factorio-headless_linux_2.0.60.tar.xz

Extract archived and zipped file

$ sudo tar -xJf factorio-headless_linux_2.0.60.tar.xz 
anon@ox:/opt$ ls -l
total 55376
drwxr-xr-x 8 factorio factorio     4096 Jul 18 05:05 factorio
-rw-r--r-- 1 root     root     56693436 Jul 10 10:05 factorio-headless_linux_2.0.60.tar.xz

Remove file (save space, you can always download the file again, if needed) using sudo rm <filename.tar.xz>

Add a new user to run factorio and assign ownership of /opt/factorio directory to same user

$ sudo useradd factorio
$ sudo chown -R factorio:factorio /opt/factorio/


Verify permissions show factorio for both user and group with ls -ld /opt/factorio

$ ls -ld /opt/factorio/
drwxr-xr-x 4 factorio factorio 4096 May  4 17:07 /opt/factorio/


Test Factorio binary by switching to factorio user then start server

robot01@apu01:/opt$ sudo su - factorio
No directory, logging in with HOME=/
$

As factorio user create /opt/factorio/ saves directory. I used saves directory.

$ mkdir /opt/factorio/saves

Start server and look for something like "File /savename does not exist."

$ /opt/factorio/bin/x64/factorio --start-server savename.zip

At this point you can load up saved games or create some games. I find it easier to create new game in Factorio client, save it, then SFTP the saved file to my headless server save directory.

Update for 2.0.60

With a base client and headless server (i.e., no mods) installation, I encountered a mod mismatch error when attempting to connect with the client. To fix this, I had to edit the default "true" values to "false" in /opt/factorio/mods/mod-list.json file for "elevated-rails", "quality", and "space-age".

Here is my mod-list.json modified file:

$ cat factorio/mods/mod-list.json  

{
  "mods": 
  [
    
    {
      "name": "base",
      "enabled": true
    },
    
    {
      "name": "elevated-rails",
      "enabled": false
    },
    
    {
      "name": "quality",
      "enabled": false
    },
    
    {
      "name": "space-age",
      "enabled": false
    }
  ]
}

Publish game on Factorio matching server

Copy /opt/factorio/data/server-settings.example.json to /opt/factorio/data/server-settings.json.

$ sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json

Edit appropriate server-settings.json values.

I used _comment_token versus password value. The appropriate value is located in %appdata%\Factorio\player-data.json under the key name "service-token". The service-token is populated after you've browsed the multiplayer servers via your Factorio game client.

My player-data.json for user "anon" on Windows was located at C:\Users\anon\AppData\Roaming\Factorio.

Make any changes to config ini

robot01@apu01:/opt/factorio$ sudo vi /opt/factorio/config/config.ini

Updating Factorio headless server

  1. Download the latest copy of the headless server using the steps above.
  2. Move and rename the headless server following the steps above.
  3. Assign ownership of /opt/factorio directory to factorio user used above.

Gaming