[Server] Factorio on any Linux, any glibc (run "anywhere")

Post all other topics which do not belong to any other category.
Post Reply
maraaaa
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Apr 14, 2018 6:42 am
Contact:

[Server] Factorio on any Linux, any glibc (run "anywhere")

Post by maraaaa »

Hello,

Inspired by this post which laments the inability to "natively" run a Factorio server on CentOS 7.4 (the current version of CentOS). After running into the same issue, and even after compiling the correct glibc, it took spelunking these forums to find out a

Code: Select all

--executable-path ./bin/x64/factorio 
was necessary... (and that's because the command was being executed from the install directory manually... trying to run factorio as a service using the custom glibc is a problem that remains unsolved...)

There are some really awesome solutions to this problem. I wanted to be able to run Factorio "natively" "Anywhere^tm". So without further ado,

Mara's Habitized Factorio

GitHub Project Page


Quick sales pitch: Habitat is a "package manager/service supervisor" that bundles all your dependencies with your application. When you run a "package" it installs exactly the libraries it was linked against at build. Also, you can export your package to any format, native, docker container, kubernetes service...

So, it's kind of a lie to say "any glibc", but there's a character limit in the title, it would be more accurate to say, "any system glibc".

This project was largely chosen as a way to learn about Habitat and Factorio, so any feedback, bug reports, feature requests, etc. are welcome and encouraged!

Installation

I'm like 95% sure this package will install and run on Windows... The whole idea is that this package is built in the "cloud" (with all the necessary deps) which allows you to run the Factorio server anywhere... We're in in short supply of Windows machines 'round here, and would love a Windows guinea pig...

For my linux users:

quickstart

Code: Select all

# not currently configurable.  needs a "hab" user for now. might change in future
sudo groupadd hab
sudo useradd -g hab hab
# download and install habitat package manager and supervisor.
curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo TMPDIR=/root bash # we assume there's noexec on /tmp and /var/tmp
# Install our factorio package
sudo hab pkg install maraaaa/factorio
# Create a map, see advanced usage for using own map
sudo hab pkg exec maraaaa/factorio factorio --create /hab/svc/factorio/data/start # Unfortunately, this is hardcoded at the moment
# start the factorio server in the foreground... this is for debugging...
sudo hab svc start maraaaa/factorio
Congrats! You now have a Running Factorio Server!

If you'd like to register your server with the main Factorio match making service, create a "server.toml" with the following content:

Code: Select all

[server-settings]
description = "Habitat Demo Server"
name = "Habitat Demo Server"
tags = ["game", "tags", "habitat"]                                                                                                                    # this is optional
username = "maraaaa"                                                                                                                                   # replace with your username
token = "a real token goes here see service-token in factorio/player-data.json after logging in"     # replace with your token
# password = "you probably shouldn't do this... but as you wish..." # comment the above line and uncomment this one to use a password instead.
(please don't store your account password in plain text anywhere... the option is included here for parity with upstream... but it shouldn't be an option at all...)

Then start your server with:

Code: Select all

sudo HAB_FACTORIO="$(cat server.toml)" hab start maraaaa/factorio
You should now be able to find your server in the multiplayer public server list!

All options can be overridden in this way. Refer to the default.toml for a list of all the options. Wherever possible configuration names have been transferred 1:1. (the place where this breaks down is in the nested hashes in JSON, you end up with "[server-settings.visibility]" for instance)

Docker Image
A public docker image is coming soon. For now, you can export a docker container on your own. Once the package is installed:

Code: Select all

hab pkg export docker maraaaa/factorio
docker run -it -p 34197:34197 maraaaa/factorio
This is totally untested, so any feedback/corrections are welcome.

Conclusion

Hope you find this useful and easy to use. Please do post any comments/questions/feedback. The most up to date information on how to use can be found on the GitHub Project Page.

- maraaaa

maraaaa
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Apr 14, 2018 6:42 am
Contact:

Re: [Server] Factorio on any Linux, any glibc (run "anywhere")

Post by maraaaa »

.

Post Reply

Return to “General discussion”