[linux] Dedicated server init script

Find multiplayer games.
Tools/scripts to run a dedicated server.
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

PCVXD wrote:It won't start on my server. When I execute service factorio start it gives an error in the debug log: could not find a pid for binary: "/opt/factorio/bin/x64/factorio". service factorio help does work. I also have all the dependencies. The Systemd part seems to be running succesfully. How can I solve this? I am a Linux newbie.
could you:
- state what version you are using
- give me a copy of your config file

(also, hit me up on irc.esper.net I'm usually idling in the [url=irc://irc.esper.net/#factorio]#factorio[/url] channel)
Hosting a factorio server? Take a look at this || init script ||.

Bonesaw
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Mar 08, 2016 3:38 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bonesaw »

Bisa wrote:...now I did not test this, but it should hopefully point you in the right direction ;)

Thanks I'll give it a shot tonight!

knope
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Apr 05, 2016 1:46 pm
Contact:

Re: [linux] Dedicated server init script

Post by knope »

very nice. Thank you :)

in the config.example wold be better fit if the following were search-and-replaced FCONF=/path/to/factorio/config/config.ini to FCONF=${FACTORIO_PATH}/config/config.ini

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

knope wrote:very nice. Thank you :)

in the config.example wold be better fit if the following were search-and-replaced FCONF=/path/to/factorio/config/config.ini to FCONF=${FACTORIO_PATH}/config/config.ini
As with this pull request: https://github.com/Bisa/factorio-init/pull/38 it would break compatibility so sorry, I will not implement it - but thank you for the suggestion :)
Hosting a factorio server? Take a look at this || init script ||.

macspawn
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Apr 12, 2016 2:11 pm
Contact:

Re: [linux] Dedicated server init script

Post by macspawn »

Hi,

If I start the server using "/etc/init.d/factorio start" it runs corretly.
But, if I start the server using "service factorio start" it gives me an error:
Error
More info
What am I doing wrong? I moved the factorio.service to /etc/init.d/ :(

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

macspawn wrote:Hi,

If I start the server using "/etc/init.d/factorio start" it runs corretly.
But, if I start the server using "service factorio start" it gives me an error:
Error
More info
What am I doing wrong? I moved the factorio.service to /etc/init.d/ :(
Hi, choose either sysvinit or systemd (depends on what your distro is working with), if you need pointers check the readme :)
https://github.com/Bisa/factorio-init/b ... /README.md
Hosting a factorio server? Take a look at this || init script ||.

macspawn
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Apr 12, 2016 2:11 pm
Contact:

Re: [linux] Dedicated server init script

Post by macspawn »

Aaah! You are right... my fault!

Thank you!

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

*bump* been fixing a few quirks in the latest commits, pull from master and update your configs =)
Hosting a factorio server? Take a look at this || init script ||.

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

adjusted for 0.13 - ensure you grab the config.example and adjust your own accordingly

happy hosting! :D
Hosting a factorio server? Take a look at this || init script ||.

klonkku
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Jul 04, 2016 12:35 pm
Contact:

Re: [linux] Dedicated server init script

Post by klonkku »

Hey,
Thanks for the script! I'm running into some issues that I hope you can help me solving :)
I'm using CentOS and I just installed Factorio headless using this guide: https://wiki.factorio.com/index.php?tit ... ayer#Linux (currently running 0.12.35). I have followed the steps you mention in here: https://github.com/Bisa/factorio-init but when I try to start the server, I get this error message:

DEBUG: write path: /opt/factorio/bin/x64/../..
DEBUG: assessing pid:
DEBUG: could not find a pid for binary: "/opt/factorio/bin/x64/factorio"

Any ideas of what I could try?

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

klonkku wrote:Any ideas of what I could try?
Hi, glad you find it useful =)

I would start by looking in the factorio-current.log, or run the start command as the factorio user manually:
cd /path/to/factorio-init
su factorio-user
source ./config
echo $INVOCATION # does it look ok?
$INVOCATION # does it start up properly, press ctrl+c to exit/abort

The script is using a 0.13 command "--start-server-load-latest" and I can Imagine if you brows the factorio-current.log this is probably mentioned - but just in case, do the above and pastebin the output if you can not see the error yourself.

(also, hit me up on irc #factorio on esper.net, I'm usually around and if Im not I'll give you a poke when I stop idling ;) )
Hosting a factorio server? Take a look at this || init script ||.

klonkku
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Jul 04, 2016 12:35 pm
Contact:

Re: [linux] Dedicated server init script

Post by klonkku »

Thanks for the extra info! In the end I just installed 0.13.4 and I got it working without a problem :-)

Cheers!

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

klonkku wrote:0.13.4
Time to update to 0.13.5 now then =P happy the script is useful =)
Hosting a factorio server? Take a look at this || init script ||.

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

I felt it was time for a new major version following the introduction of pidfile and fifo - please enjoy 2.0.0
Hosting a factorio server? Take a look at this || init script ||.

tacgnol
Inserter
Inserter
Posts: 36
Joined: Sun May 29, 2016 3:51 am
Contact:

Re: [linux] Dedicated server init script

Post by tacgnol »

Thanks Bisa for your script.

One question ...


I was using the previous init version. Now with systemd, how can I run the update script ?

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

tacgnol wrote:how can I run the update script ?
Hi, glad you find this useful; Using systemd does not prevent you from also running the script itself - for example "/opt/factorio-init/factorio update"
What I like to do is symlinking the factorio script to /usr/local/bin or adding it to my PATH in any other way, then I'll just type "factorio update"

(Take care when using the scripts start/stop/restart methods tho, since you really want systemd to be aware of these events its best to ignore these and rely on "systemctl start/stop/restart factorio" instead)
Hosting a factorio server? Take a look at this || init script ||.

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

version 2.2.0 introduces cmd output being returned to you whenever you run a command, this will allow you to view the online players directly from a terminal for example
Hosting a factorio server? Take a look at this || init script ||.

edalquist
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jul 14, 2016 7:42 pm
Contact:

Re: [linux] Dedicated server init script

Post by edalquist »

I'm trying to use the latest version of the script with Factorio 0.13.8 via systemctl and get a timeout error:

Code: Select all

edalquist@factorio:~$ sudo systemctl start factorio
Job for factorio.service failed because a timeout was exceeded. See "systemctl status factorio.service" and "journalctl -xe" for details.

edalquist@factorio:~$ systemctl status factorio.service
● factorio.service - Factorio Server
   Loaded: loaded (/etc/systemd/system/factorio.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: timeout) since Thu 2016-07-14 19:40:54 UTC; 10s ago
  Process: 25143 ExecStart=/opt/factorio-init/factorio start (code=exited, status=0/SUCCESS)

Jul 14 19:40:54 factorio systemd[1]: Failed to start Factorio Server.
Jul 14 19:40:54 factorio systemd[1]: factorio.service: Unit entered failed state.
Jul 14 19:40:54 factorio systemd[1]: factorio.service: Failed with result 'timeout'.

Looking in factorio-current.log I see a normal startup and then after the timeout passes (which I even increased from 20s to 60s) I see:

Code: Select all

60.224 Received SIGTERM, shutting down
I captured the CLI used by factorio to start the server:

Code: Select all

0.054 Program arguments: "/opt/factorio/factorio/bin/x64/factorio" "--config" "/opt/factorio/factorio/config/config.ini" "--port" "34197" "--start-server-load-latest" "--server-settings" "/opt/factorio/factorio/data/server-settings.json" "--autosave-interval" "10" "--autosave-slots" "6" "--latency-ms" "250" "--allow-commands" "admin-only" 
Running that manually the server starts and runs correctly though it doesn't ever return control of the terminal.

Is there a config change I need to make to get the script to properly background the process?

This is on Ubuntu 16.04 LTS

Code: Select all

$ uname -a
Linux factorio 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

edalquist
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Jul 14, 2016 7:42 pm
Contact:

Re: [linux] Dedicated server init script

Post by edalquist »

Never mind .... I didn't read the comments in factorio.service.example

Because of poor planning (and lazyness) I have factorio installed in /opt/factorio/factorio

I just needed to change the PIDFile var in the factorio.service file to point to the correct directory.

Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

edalquist wrote:Never mind .... I didn't read the comments in factorio.service.example
glad you got it working =D also, thnx for the detailed help request, if you ever run into any other problems be sure to keep the detail level - much appreciated
Hosting a factorio server? Take a look at this || init script ||.

Post Reply

Return to “Multiplayer / Dedicated Server”