Dedicated Multiplayer Server Guide

Find multiplayer games.
Tools/scripts to run a dedicated server.
bkg
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Dec 09, 2014 5:28 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by bkg »

On, i have now a char but get Stuck in the other one !

I try now to delete him again
bkg
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Dec 09, 2014 5:28 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by bkg »

Code: Select all

eysho@dev:~/private/factorio_alpha_x64_0.11.5$ wc -l /var/www/vhosts/factorio/private/factorio_alpha_x64_0.11.5/factorio-current.log | grep -o "[0-9]\+"
7
64
0
11
5
eysho@dev:~/private/factorio_alpha_x64_0.11.5$ ./pauser
./pauser: line 11: 7
64
0
11
5: syntax error in expression (error token is "64
0
11
5")
eysho@dev:~/private/factorio_alpha_x64_0.11.5$
Thats the error and you see teh grep work over shell
bkg
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Dec 09, 2014 5:28 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by bkg »

Ok now i have the problem that not 2 players can connect simul. anny idea why?

The peer broke, and he show the ip from the guy thats allready in, for no peer to ip. XX User 1 . But why peer to user. and not to server?

The user connect and then the console reload he show User () and user x and y , and reload.
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Alkalyne »

Hello, for your pauser script, what is your Operating System ?
can you add :
wc -l /var/www/vhosts/factorio/private/factorio_alpha_x64_0.11.5/factorio-current.log | grep -o "[0-9]\+" | head -1
in the script ?

And for your last problem I don't know maybe a 0.11.5 bug (I know there is some problems with 0.11.4 and 0.11.5)
The user connect and then the console reload he show User () and user x and y , and reload.
I don't know what do you mean.

I don't know how the multiplayer works, but maybe there is a problem between user 1 and user 2 ? Are you on the same network ? maybe a firewall problem ?
bkg
Burner Inserter
Burner Inserter
Posts: 8
Joined: Tue Dec 09, 2014 5:28 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by bkg »

Ok after i edit the pasuer looks so :

bkg@dev:~/private/server/factorio.bkg.me/v0.11.3$ ./pauser_v0.11.3
QUITS: 1
JOINS: 1
JOINSGAME:1
BOOT : Pause on Boot
./pauser_v0.11.3: line 44: bc: command not found
./pauser_v0.11.3: line 45: bc: command not found
Usage: mousemove [options] <x> <y>
-c, --clearmodifiers - reset active modifiers (alt, etc) while typing
--screen SCREEN - which screen to move on, default is current screen
--sync - only exit once the mouse has moved
-w, --window <windowid> - specify a window to move relative to.
You specified the wrong number of args (expected 2 coordinates or 'restore').
Paused
0
QUITS: 0
JOINS: 0
JOINSGAME:0
0
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Alkalyne »

you need to install bc

Code: Select all

apt-get install bc
:
przerwap
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Aug 29, 2014 9:01 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by przerwap »

Parsing the log seems like such a ghetto hack.. Why not just have the client do the pausing/unpausing directly from the game?

EDIT: And by 'client' I mean the 'dedicated server'
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Alkalyne »

All this guide is a hack waiting for an official release.

Dedicaced server mode is not supported by the game, and the multiplayer is really buggy.

We parse the log to see when a player connect and we pause/unpause the game. It works, so why do you want to do it in another way ?

Code: Select all

 directly from the game?
How ?

If you know how to do it in another way you can share the information
przerwap
Manual Inserter
Manual Inserter
Posts: 3
Joined: Fri Aug 29, 2014 9:01 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by przerwap »

All you're doing is counting the number of players by parsing the log, no? Why not just use the built-in LUA scripting to simply check if(games.players.length == 1) { game.pause(); } else { game.unpause() }
harch
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Jan 20, 2015 7:37 am
Contact:

Re: Dedicated Multiplayer Server Guide

Post by harch »

if(games.players.length == 1) { game.pause(); } else { game.unpause() }
unfortunately there is no such function
i tried to reduce game speed to 0.1(it's minimum)
but i'm not too good in lua to do it, so just nothing happens

is there someone who got working solution for 0.11.13 without using xdotool?
nimh
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 19, 2015 7:49 am
Contact:

Re: Dedicated Multiplayer Server Guide

Post by nimh »

Alkalyne wrote:I just made a change in the startfactorio script :

Code: Select all

name=$(find /path/to/factorio/saves -type f -printf '%T@ %f\n' | sort -n | tail -1 | cut -f2- -d" ")
That's allows to restart factorio easily using the last autosave.

NOTE : The pauser script don't work, since the key Shift+space does not pause the game in multiplayer since 11.2 ( :( )

But with the autosave I just need to stop the game to start it later

EDIT :
I have updated the pauser script, now it will pause the game :

Code: Select all

#!/bin/bash
PATHTOLOG="/var/www/factorio/factorio-current.log"

OLDPLAYERCOUNT=0
PLAYERCOUNT=0
NUMBEROFLINESOLD=0
 
while :; do
  #get the current nuber of log entries
  NUMBEROFLINES=$(wc -l /var/www/factorio/factorio-current.log | grep -o "[0-9]\+")
  ABSOLUTELINES=$((NUMBEROFLINES-NUMBEROFLINESOLD))
  #only look at new lines
  TAILEDLOG=$(tail -$ABSOLUTELINES $PATHTOLOG)
  #grab Joins PlayerJoinGame
  JOINSGAME=$(echo $TAILEDLOG | grep "MultiplayerManager changing state from(InGameSendingMap) to(InGame)" | wc -l | grep -o "[0-9]\+")
  #grab peer leaving
  QUITS=$(echo $TAILEDLOG | grep "PlayerLeaveGame" | wc -l | grep -o "[0-9]\+")
  #grab peer timeout
  DROPOUTS=$(echo $TAILEDLOG | grep "is not responding, dropping" | wc -l | grep -o "[0-9]\+")
  BOOT=$(echo $TAILEDLOG | grep "MultiplayerManager changing state from(CreatingGame) to(InGame)" | wc -l | grep -o "[0-9]\+")
  QUITS=$((QUITS+DROPOUTS))
  echo "QUITS: "$QUITS
  JOINS=$((JOINSGAME))
  echo "JOINS: "$JOINS
  echo "JOINSGAME:"$JOINSGAME
  PLAYERCOUNT=$((PLAYERCOUNT+JOINS))
  PLAYERCOUNT=$((PLAYERCOUNT-QUITS))
  if [ $BOOT -eq 1 ]
  then
	echo "BOOT : Pause on Boot"
	WID=$(xdotool search Factorio 2>/dev/null)
	xdotool windowactivate --sync $WID
	unset x y w h
        #need to press Escape once because of the Audio popup
        xdotool key Escape
	sleep 1
        xdotool key Escape
	sleep 1
        eval $(xwininfo -id $(xdotool getactivewindow) |
        sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
        width=`echo "0.5 * $w" | bc`
        height=`echo "0.45 * $h" | bc`
        xdotool mousemove --window $WID $width $height
        xdotool click 1
	sleep 1
	xdotool key Escape
	echo "Paused"
  fi
 
  if [ $PLAYERCOUNT -eq 1 -a $OLDPLAYERCOUNT -eq 0 ]
  then
	echo "detected players, unpausing"
	WID=$(xdotool search Factorio 2>/dev/null)
	xdotool windowactivate --sync $WID
	unset x y w h
	xdotool key Escape
	sleep 1
	eval $(xwininfo -id $(xdotool getactivewindow) |
	sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
	width=`echo "0.5 * $w" | bc`
	height=`echo "0.45 * $h" | bc`
	xdotool mousemove --window $WID $width $height
	xdotool click 1
	sleep 1
	xdotool key Escape
  fi
  if [ $PLAYERCOUNT -eq 0 -a $OLDPLAYERCOUNT -eq 1 ]
  then
	echo "0 players, pausing"
	WID=$(xdotool search Factorio 2>/dev/null)
	xdotool windowactivate --sync $WID
	        unset x y w h
        xdotool key Escape
	sleep 1
        eval $(xwininfo -id $(xdotool getactivewindow) |
        sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
        width=`echo "0.5 * $w" | bc`
        height=`echo "0.45 * $h" | bc`
        xdotool mousemove --window $WID $width $height
        xdotool click 1
	sleep 1
	xdotool key Escape
  fi
 
 
  #REMOVE the following line if you don't want to see current players.
  echo $PLAYERCOUNT
 
  OLDPLAYERCOUNT=$PLAYERCOUNT
  NUMBEROFLINESOLD=$NUMBEROFLINES
  #change to number of seconds between player count update [default: 1 sec]
  sleep 1
done
Got everything working well except for the pauser script. It's not tracking joins, shows 0, then when I quit it counts a quit, and puts the total to -1.

Pretty sure I should see the pauser script pausing the game though, before I jump on and I'm not seeing that. I received some errors launching startxfce4 but I'm unable to tell if it's properly working or not, are there logs I can find, or a specific message I should be seeing?

Running this on .14, any ideas?
User avatar
Piranha
Fast Inserter
Fast Inserter
Posts: 152
Joined: Fri Nov 21, 2014 8:15 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Piranha »

nimh, put metal plates in a box with an inserter outputting onto a 500 tile long belt then back into a box.. start the system, let it run 1/4 of the way down the belt, leave the game, wait a few minutes, join back.. If the plates reached the end and were put into the end box then the game didn't pause, if you come back in and the plates are only 1/4 of the way down the belt then you know the game paused..

At least I think that would work... haha
nimh
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Feb 19, 2015 7:49 am
Contact:

Re: Dedicated Multiplayer Server Guide

Post by nimh »

Piranha wrote:nimh, put metal plates in a box with an inserter outputting onto a 500 tile long belt then back into a box.. start the system, let it run 1/4 of the way down the belt, leave the game, wait a few minutes, join back.. If the plates reached the end and were put into the end box then the game didn't pause, if you come back in and the plates are only 1/4 of the way down the belt then you know the game paused..

At least I think that would work... haha
Oh nice, that's a good way to check it's pausing. Going to give this entire set-up another try and see if I can get it working. The pauser script is really the key to all of this though, without it, the biters just get worse and worse while the server stays up. Coming back to a map with 2-3 full days worth of biter spawn can be a headache.
Eirikaine
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 11, 2015 7:38 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Eirikaine »

Hello everybody ! :)

After following this guide and updated it to work with the version 0.11.20, everything work fine for me and my friend.
But is was before the tragedy...
Something that I forgot to check was the automatic save game.. And you know what ? The automatic save game is not working, so we are... F**KED :lol:

Does the automatic save game is not working because some of black magic or is it caused by the "--mp-load-game" parameter ?
It could be good if a person with a purple alien icon can answer about this :D
And by the way, can we have more information about a command only launcher of the game ? Or the possibility to put the game in a pause state with a mod (game.pause ?
edit: the log refer to "Verbose Synchronizer.cpp:294: [...] Processing synchronizer action(BeginPause)..."
It shouldn't be that much too complicate to make this action(BeginPause) callable by a mod devs nope ? :P
).

By the way² : is there a possibility to trigger the save-gaming with a mod ? I saw the "game.save()" method but it seems to set the path of the save game only (not sure about this!)

Thank you in advance for the future answers !
Interested by modding, multiplayer and often active on IRC
No native English speaker.
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Alkalyne »

Hello,

When I started (few month ago) to run my dedicaced server the Autosave was working fine.
Maybe the game does not have the right to write in the save directory ? Try to change this.

You need to check logs, maybe you can see where is the problem.
Eirikaine
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 11, 2015 7:38 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Eirikaine »

Hmm, I'm almost sure that the folder have rwx for everything (chmod 777 if you know what i mean) but I admit not having paid attention to logs about autosaves :oops:

I'll check it when i can and edit this post if i found something interesting :)
Interested by modding, multiplayer and often active on IRC
No native English speaker.
jonathans
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri May 01, 2015 4:15 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by jonathans »

just wanted to add a note for linux server admins who usually run headless; as you know, you won't have an xorg.conf or any video device. but if you just install the dummy device and use the follow xorg.conf you shouldn't have any problems. i use debian, so this should be similar or identical to ubuntu.

Code: Select all

apt-get install xserver-xorg-video-dummy
/etc/X11/xorg.conf:

Code: Select all

Section "Monitor"
	Identifier	"Monitor0"
EndSection

Section "Device"
	Identifier	"Card0"
	Option		"NoDDC"		"true"
	Option		"IgnoreEDID"	"true"
	Driver		"dummy"
EndSection

Section "Screen"
	Identifier	"Screen0"
	Device		"Card0"
	Monitor		"Monitor0"
EndSection
also note that running xset without previously specifying a display in the same session will spit out an error. either export DISPLAY or just prepend the command with just-in-time environment variables, as usual:

Code: Select all

DISPLAY=:10 xset s off
Nukesor
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat May 30, 2015 8:33 am
Contact:

High load on Factorio Server

Post by Nukesor »

Hi there!

First of all, thanks for this guide!
I tried to run this on my root server and ran into a few problems.
After starting the game, factorio used 8 cores with an average of 80% load on each core.
At first I would recommend using openbox rather than xfce. It's just a windowmanager and more lightweight than xfce.
But the most important thing is: Most root server come without a graphic card, which means that everything is rendered with your CPU!! To mitigate this drawback I resized the factorio window inside the dummy screen to 1 pixel. A size every CPU can handle ;).

Here are my scripts. Btw: I used tmux instead of screen, since it's IMO more convenient.

https://github.com/Nukesor/gamescripts/ ... actorio.sh

Code: Select all

#!/bin/bash

# New tmux session for x server
tmux new -d -s x
tmux send -t x sudo SPACE Xorg SPACE -noreset SPACE +extension SPACE GLX SPACE +extension SPACE RANDR SPACE +extension SPACE RENDER SPACE -logfile SPACE ./factorio/10.log SPACE -config SPACE ./factorio/xorg.conf SPACE :10 ENTER
# Attach to session for entering sudo password. 
# Session can be left with CTRL+b +d
tmux attach -t x

https://github.com/Nukesor/gamescripts/ ... Startup.sh

Code: Select all

#!/bin/bash

# Start openbox Window Manager in new tmux session
tmux new -d -s openbox
tmux send -t openbox export SPACE DISPLAY=:10 ENTER
tmux send -t openbox exec SPACE openbox-session ENTER

# Disable Screensaver
xset s off

# Start factorio in new tmux session
tmux new -d -s factorio
tmux send -t factorio export SPACE DISPLAY=:10 ENTER
tmux send -t factorio factorio/bin/x64/factorio SPACE --mp-load-game SPACE world.zip ENTER

# Wait for the game starting up and opening the window
sleep 3

export DISPLAY=:10
# Get the Window ID
WID=$(xdotool search --name "Factorio 0.11.22")
# Resize the Window to 1x1 Pixel
xdotool windowsize $WID 1 1
There are also some scripts for clientside restart of the server or map syncing. Hope it helps ;).

Nuke
Rooski
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu May 08, 2014 9:28 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Rooski »

im getting these errors , i assume its cause im running a debian os...

any info guys ?

Code: Select all

/var/games/Factorio/bin/x64/factorio: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /var/games/Factorio/bin/x
64/factorio)                                                                                                                                
/var/games/Factorio/bin/x64/factorio: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.15' not found (required by /var/games/Factorio/bin/x
64/factorio)                                                                                                                                
/var/games/Factorio/bin/x64/factorio: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.15' not found (required by /var/games/Factorio/bin/x
64/factorio) 
Alkalyne
Inserter
Inserter
Posts: 25
Joined: Sun Jun 15, 2014 11:39 pm
Contact:

Re: Dedicated Multiplayer Server Guide

Post by Alkalyne »

It's because you don't have the lastest version of libc.so (required by factorio), it's not available in wheezy with apt-get because wheezy is oldstable

I know you can force the install of a new version but I don't remember how
Post Reply

Return to “Multiplayer / Dedicated Server”