Difference between revisions of "My Factorio Info"

From Got Opinion Wiki
Jump to navigation Jump to search
(initial page creation)
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Factorio Headless Setup ==
== Factorio Headless Setup ==
'''These steps were done with Ubuntu 22.04.3 LTS'''


Resources:
Resources:
Line 5: Line 7:
* 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.
Written by Roland McGrath and Ulrich Drepper.</pre>
Written by Roland McGrath and Ulrich Drepper.</pre>


Output of ldd command confirms glibc version 2.23.
Output of ldd command confirms glibc version >2.18.


Switch to <code>/opt</code> directory and download latest Factorio stable headless version (0.16.36 as of this writing)
Switch to <code>$ cd /opt</code> directory and download latest Factorio stable headless version (1.1.107 as of this writing)
<pre>robot01@apu01:~$ cd /opt
 
robot01@apu01:/opt$ sudo wget https://factorio.com/get-download/stable/headless/linux64
<pre>$ sudo wget https://factorio.com/get-download/stable/headless/linux64
...
[sudo] password for anon:  
...
Sorry, try again.
...
[sudo] password for anon:
--2024-05-04 16:59:05--  https://factorio.com/get-download/stable/headless/linux64
Resolving factorio.com (factorio.com)... 2606:4700:20::ac43:47c5, 2606:4700:20::681a:f58, 2606:4700:20::681a:e58, ...
Connecting to factorio.com (factorio.com)|2606:4700:20::ac43:47c5|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|2606:4700:20::681a:f58|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|2606:4700:20::681a:e58|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|104.26.15.88|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.factorio.com/releases/1.1.107_01hv6kd1ctem7tvfd5tbq1vtw8/factorio_headless_x64_1.1.107.tar.xz?secure=_GqQEFiF6ELNO_2x-zqWdg,1714845555 [following]
--2024-05-04 16:59:15--  https://dl.factorio.com/releases/1.1.107_01hv6kd1ctem7tvfd5tbq1vtw8/factorio_headless_x64_1.1.107.tar.xz?secure=_GqQEFiF6ELNO_2x-zqWdg,1714845555
Resolving dl.factorio.com (dl.factorio.com)... 2a02:6ea0:f900::3, 109.61.86.69
Connecting to dl.factorio.com (dl.factorio.com)|2a02:6ea0:f900::3|:443... failed: No route to host.
Connecting to dl.factorio.com (dl.factorio.com)|109.61.86.69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57164752 (55M) [application/octet-stream]
Saving to: ‘linux64’
Saving to: ‘linux64’


linux64                           100%[==========================================================>]  54.53M 52.4MB/s    in 1.0s    
linux64                       100%[=================================================>]  54.52M 51.3MB/s    in 1.1s    


2022-04-09 09:36:49 (52.4 MB/s) - ‘linux64’ saved [57178436/57178436]</pre>
2024-05-04 16:59:19 (51.3 MB/s) - ‘linux64’ saved [57164752/57164752]</pre>


Rename file to match version (1.1.57 in this example)
Rename file to match version (1.1.87 in this example)
<pre>robot01@apu01:/opt$ sudo mv linux64 factorio_headless_x64_1.1.57.tar.xz</pre>
<pre>$ sudo mv linux64 factorio_headless_x64_1.1.107.tar.xz</pre>


Extract archived and zipped file
Extract archived and zipped file
<pre>robot01@apu01:/opt$ sudo tar -xJf factorio_headless_x64_1.1.57.tar.xz
<pre>$ sudo tar -xJf factorio_headless_x64_1.1.107.tar.xz
robot01@apu01:/opt$ ls -l
$ ls -l
total 55844
total 55832
drwxr-xr-x 8 steamy steamy     4096 Apr 9 09:38 factorio
drwxr-xr-x 4 root root     4096 May 4 17:07 factorio
-rw-r--r-- 1 root   root   57178436 Mar 29 08:42 factorio_headless_x64_1.1.57.tar.xz</pre>
-rw-r--r-- 1 root root 57164752 Apr 11 13:40 factorio_headless_x64_1.1.107.tar.xz</pre>


Remove file (save space, you can always download again if needed)
Remove file (save space, you can always download the file again, if needed)
<pre>robot01@apu01:/opt$ sudo rm factorio_headless_x64_1.1.57.tar.xz</pre>
<pre>robot01@apu01:/opt$ sudo rm factorio_headless_x64_1.1.107.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
<pre>robot01@apu01:/opt$ sudo useradd factorio
<pre>$ sudo useradd factorio
robot01@apu01:/opt$ sudo chown -R factorio:factorio /opt/factorio/</pre>
$ sudo chown -R factorio:factorio /opt/factorio/</pre>




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>robot01@apu01:/opt$ ls -l
<pre>$ ls -ld /opt/factorio/
total 4
drwxr-xr-x 4 factorio factorio 4096 May  4 17:07 /opt/factorio/</pre>
drwxr-xr-x 4 factorio factorio 4096 May  1 21:12 factorio</pre>




Line 56: Line 71:
No directory, logging in with HOME=/
No directory, logging in with HOME=/
$</pre>
$</pre>
As factorio user create <code>/opt/factorio/</code> saves directory. I used saves directory.
<pre>$ mkdir /opt/factorio/saves</pre>


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
   0.000 2018-05-01 21:20:47; Factorio 0.16.36 (build 36253, linux64, headless)
   0.000 2024-05-04 17:53:44; Factorio 1.1.107 (build 62234, linux64, headless)
   0.260 Operating system: Linux (Ubuntu 16.04)
   0.020 Operating system: Linux (Ubuntu 22.04)
   0.260 Program arguments: "/opt/factorio/bin/x64/factorio" "--start-server" "savename"
   0.020 Program arguments: "/opt/factorio/bin/x64/factorio" "--start-server" "savename"  
   0.260 Read data path: /opt/factorio/data
   0.020 Config path: /opt/factorio/config/config.ini
   0.260 Write data path: /opt/factorio [103696/111098MB]
  0.020 Read data path: /opt/factorio/data
   0.260 Binaries path: /opt/factorio/bin
   0.020 Write data path: /opt/factorio [1763296/1874134MB]
   0.304 System info: [CPU: AMD G-T40E Processor, 2 cores, RAM: 3550 MB]
   0.020 Binaries path: /opt/factorio/bin
   0.304 Environment: DISPLAY=<unset>, WAYLAND_DISPLAY=<unset>
   0.024 System info: [CPU: 13th Gen Intel(R) Core(TM) i9-13900K, 32 cores, RAM: 64055 MB]
   0.305 Running in headless mode
   0.024 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=<unset> DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> __GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   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.024 Running in headless mode
  0.322 Loading mod core 0.0.0 (data.lua)
   0.046 Loading mod core 0.0.0 (data.lua)
   0.388 Loading mod base 0.16.36 (data.lua)
   0.062 Loading mod base 1.1.107 (data.lua)
   1.063 Loading mod base 0.16.36 (data-updates.lua)
   0.152 Loading mod base 1.1.107 (data-updates.lua)
   1.313 Checksum for core: 1316978547
   0.182 Checksum for core: 607699937
   1.313 Checksum of base: 4140083139
   0.182 Checksum of base: 1054619811
   2.006 Info PlayerData.cpp:67: Local player-data.json unavailable
   0.277 Prototype list checksum: 3034860339
   2.006 Info PlayerData.cpp:72: Cloud player-data.json unavailable
  0.299 Info PlayerData.cpp:78: Local player-data.json unavailable
   2.012 Custom inputs active: 0
   0.299 Info PlayerData.cpp:83: Cloud player-data.json unavailable
  2.015 Factorio initialised
   0.301 Factorio initialised
   2.016 Info ServerSynchronizer.cpp:29: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
   0.302 Info ServerSynchronizer.cpp:29: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
   2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(Ready) to(PreparedToHostGame)
   0.302 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(Ready) to(PreparedToHostGame)
   2.016 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(PreparedToHostGame) to(CreatingGame)
   0.302 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(PreparedToHostGame) to(CreatingGame)
   2.017 Loading map /savename
   0.304 Loading map /opt/factorio/savename
   2.017 Error ServerMultiplayerManager.cpp:96: MultiplayerManager failed: "File /savename does not exist."
   0.305 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "File /opt/factorio/savename does not exist."
   2.017 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(CreatingGame) to(InitializationFailed)
   0.305 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(CreatingGame) to(InitializationFailed)
   2.017 Info GlobalContext.cpp:694: Waiting for child processes to exit:
   0.305 Info CommandLineMultiplayer.cpp:219: Exit point.
   2.020 Info ServerMultiplayerManager.cpp:142: Quitting multiplayer connection.
   0.306 Info ServerMultiplayerManager.cpp:154: Quitting multiplayer connection.
   2.020 Info ServerMultiplayerManager.cpp:698: mapTick(4294967295) changing state from(InitializationFailed) to(Closed)
   0.306 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(InitializationFailed) to(Closed)
   2.062 Info UDPSocket.cpp:206: Closing socket
   0.321 Info UDPSocket.cpp:233: Closing socket
   2.065 Goodbye</pre>
   0.322 Goodbye</pre>
 
As factorio user create <code>/opt/factorio/</code> saves directory
<pre>$ mkdir /opt/factorio/saves</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.


Exit from factorio user back to sudo account
<pre>$ exit
logout</pre>


Switch to <code>/opt</code> directory
== Publish game on Factorio matching server ==
<pre>robot01@apu01:/opt/factorio$ cd /opt</pre>


Clone Factorio init script from github
Copy /opt/factorio/data/server-settings.example.json to /opt/factorio/data/server-settings.json.
<pre>robot01@apu01:/opt$ sudo git clone https://github.com/Bisa/factorio-init.git
Cloning into 'factorio-init'...
remote: Counting objects: 484, done.
remote: Total 484 (delta 0), reused 0 (delta 0), pack-reused 484
Receiving objects: 100% (484/484), 109.47 KiB | 0 bytes/s, done.
Resolving deltas: 100% (276/276), done.
Checking connectivity... done.</pre>


Make Factorio start on operating system boot and restart if failure (configurable - I kept defaults for now)
<pre>$ sudo cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json</pre>
<pre>robot01@apu01:/opt$ sudo cp /opt/factorio-init/factorio.service.example /etc/systemd/system/factorio.service
robot01@apu01:/opt$ sudo systemctl daemon-reload</pre>


Sysvinit
Edit appropriate server-settings.json values.
<pre>robot01@apu01:/opt/factorio$ sudo ln -s /opt/factorio-init/factorio /etc/init.d/factorio
robot01@apu01:/opt/factorio$ sudo chmod +x /opt/factorio-init/factorio</pre>


Show help
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>robot01@apu01:/opt/factorio$ service factorio help
Usage: /etc/init.d/factorio COMMAND


Available commands:
My player-data.json for user "anon" on Windows was located at C:\Users\anon\AppData\Roaming\Factorio.
  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
  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
  help                                  Shows this help message</pre>
 
Setup Autocompletion
<pre>robot01@apu01:/opt/factorio$ sudo ln -s /opt/factorio-init/bash_autocomplete /etc/bash_completion.d/factorio
robot01@apu01:/opt/factorio$ sudo echo "source /opt/factorio-init/bash_autocomplete" >> ~/.bashrc</pre>
 
Copy example server settings (make any changes you want to copy)
<pre>robot01@apu01:/opt/factorio$ 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>robot01@apu01:/opt/factorio$ sudo cp /opt/factorio-init/config.example /opt/factorio-init/config</pre>


Make any changes to config ini
Make any changes to config ini
Line 166: Line 136:
change permissions to your dedicated factorio user
change permissions to your dedicated factorio user


<pre>sudo chown -R steamy:steamy factorio</pre>
<pre>sudo chown -R factorio:factorio factorio</pre>
 
launch game, example with saved game called "spoon.zip":


launch game
<pre>/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/spoon.zip</pre>


[[Gaming]]
[[Gaming]]

Latest revision as of 14:02, 4 May 2024

Factorio Headless Setup

These steps were done with Ubuntu 22.04.3 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 (1.1.107 as of this writing)

$ sudo wget https://factorio.com/get-download/stable/headless/linux64
[sudo] password for anon: 
Sorry, try again.
[sudo] password for anon: 
--2024-05-04 16:59:05--  https://factorio.com/get-download/stable/headless/linux64
Resolving factorio.com (factorio.com)... 2606:4700:20::ac43:47c5, 2606:4700:20::681a:f58, 2606:4700:20::681a:e58, ...
Connecting to factorio.com (factorio.com)|2606:4700:20::ac43:47c5|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|2606:4700:20::681a:f58|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|2606:4700:20::681a:e58|:443... failed: No route to host.
Connecting to factorio.com (factorio.com)|104.26.15.88|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.factorio.com/releases/1.1.107_01hv6kd1ctem7tvfd5tbq1vtw8/factorio_headless_x64_1.1.107.tar.xz?secure=_GqQEFiF6ELNO_2x-zqWdg,1714845555 [following]
--2024-05-04 16:59:15--  https://dl.factorio.com/releases/1.1.107_01hv6kd1ctem7tvfd5tbq1vtw8/factorio_headless_x64_1.1.107.tar.xz?secure=_GqQEFiF6ELNO_2x-zqWdg,1714845555
Resolving dl.factorio.com (dl.factorio.com)... 2a02:6ea0:f900::3, 109.61.86.69
Connecting to dl.factorio.com (dl.factorio.com)|2a02:6ea0:f900::3|:443... failed: No route to host.
Connecting to dl.factorio.com (dl.factorio.com)|109.61.86.69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57164752 (55M) [application/octet-stream]
Saving to: ‘linux64’

linux64                        100%[=================================================>]  54.52M  51.3MB/s    in 1.1s    

2024-05-04 16:59:19 (51.3 MB/s) - ‘linux64’ saved [57164752/57164752]

Rename file to match version (1.1.87 in this example)

$ sudo mv linux64 factorio_headless_x64_1.1.107.tar.xz

Extract archived and zipped file

$ sudo tar -xJf factorio_headless_x64_1.1.107.tar.xz
$ ls -l
total 55832
drwxr-xr-x 4 root root     4096 May  4 17:07 factorio
-rw-r--r-- 1 root root 57164752 Apr 11 13:40 factorio_headless_x64_1.1.107.tar.xz

Remove file (save space, you can always download the file again, if needed)

robot01@apu01:/opt$ sudo rm factorio_headless_x64_1.1.107.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
   0.000 2024-05-04 17:53:44; Factorio 1.1.107 (build 62234, linux64, headless)
   0.020 Operating system: Linux (Ubuntu 22.04)
   0.020 Program arguments: "/opt/factorio/bin/x64/factorio" "--start-server" "savename" 
   0.020 Config path: /opt/factorio/config/config.ini
   0.020 Read data path: /opt/factorio/data
   0.020 Write data path: /opt/factorio [1763296/1874134MB]
   0.020 Binaries path: /opt/factorio/bin
   0.024 System info: [CPU: 13th Gen Intel(R) Core(TM) i9-13900K, 32 cores, RAM: 64055 MB]
   0.024 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=<unset> DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> __GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   0.024 Running in headless mode
   0.046 Loading mod core 0.0.0 (data.lua)
   0.062 Loading mod base 1.1.107 (data.lua)
   0.152 Loading mod base 1.1.107 (data-updates.lua)
   0.182 Checksum for core: 607699937
   0.182 Checksum of base: 1054619811
   0.277 Prototype list checksum: 3034860339
   0.299 Info PlayerData.cpp:78: Local player-data.json unavailable
   0.299 Info PlayerData.cpp:83: Cloud player-data.json unavailable
   0.301 Factorio initialised
   0.302 Info ServerSynchronizer.cpp:29: nextHeartbeatSequenceNumber(0) initialized Synchronizer nextTickClosureTick(0).
   0.302 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(Ready) to(PreparedToHostGame)
   0.302 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(PreparedToHostGame) to(CreatingGame)
   0.304 Loading map /opt/factorio/savename
   0.305 Error ServerMultiplayerManager.cpp:92: MultiplayerManager failed: "File /opt/factorio/savename does not exist."
   0.305 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(CreatingGame) to(InitializationFailed)
   0.305 Info CommandLineMultiplayer.cpp:219: Exit point.
   0.306 Info ServerMultiplayerManager.cpp:154: Quitting multiplayer connection.
   0.306 Info ServerMultiplayerManager.cpp:814: updateTick(4294967295) changing state from(InitializationFailed) to(Closed)
   0.321 Info UDPSocket.cpp:233: Closing socket
   0.322 Goodbye

At this point you can load up saved games or create some games.


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

Update headless server

download latest headless version

unzip and untar

sudo tar -xJf linux64

change permissions to your dedicated factorio user

sudo chown -R factorio:factorio factorio

launch game, example with saved game called "spoon.zip":

/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/spoon.zip

Gaming