Linux dedicated server

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Linux dedicated server

Post by MagicBuzz » 28 Nov 2019 20:22

Hello,

I would like to pubish a dedicated server running under linux.
I can run VMs with Ubuntu or Debian without screen (so no desktop environment) with an ARM64 CPU.

I found I can download and install openttd using aptitude.
But :
1/ I read somewhere the packages from official Linux repositories are out of date (version 1.6 or so ?)
2/ When I install it... I can't find how to run a server without launching the game itself with GUI (through SSH it's quite hard...)

So I'm looking for two things :
1/ A script or tutorial explaining how to pull the source directly from a GIT repository and compile it for ARM64
2/ The command line that actually run a dedicated server without GUI... and some explanations on how to configure it

Any idea where I could find those ?

agentw4b
Traffic Manager
Traffic Manager
Posts: 156
Joined: 14 Apr 2017 15:51
Location: Czech Republic

Re: Linux dedicated server

Post by agentw4b » 29 Nov 2019 06:01

Owner and admin of servers:Experimental games 01 (92.63.57.152:3979), Experimental games 02 (92.63.57.152:3879), Experimental games 03 (92.63.57.152:3779), Experimental games 04 (92.63.57.152:3679), Experimental games 05 (92.63.57.152:3579).
My heightmaps: Flat Earth Map and United nations logo
My scenarios: Game Fallout 1,2,3 Map scenario
My gamescripts: City Founder GS


User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9332
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Linux dedicated server

Post by planetmaker » 29 Nov 2019 09:23

Generally it's advisable to simply build OpenTTD from source for a server. Especially on linux that's an easy thing to do - you don't need all the GUI stuff. The wiki page andy linked is more verbose, however the short version:

assuming a debian-based linux (which also applies to ubuntu):

Code: Select all

apt-get install build-essential
apt-get build-dep openttd
Then get source

Code: Select all

git clone https://github.com/OpenTTD/OpenTTD/ server-source
Checkout desired version and build (repeat this and following steps each time you update your OpenTTD version):

Code: Select all

cd server-source
git checkout 1.10.0-beta1
./configure --enable-dedicated
make bundle
and if you're clever, run from a different directory, so you can update in the background:

Code: Select all

cd
mkdir server
cp -r server-source/bundle/* server
start the server:

Code: Select all

server/openttd -D -f

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: Linux dedicated server

Post by MagicBuzz » 29 Nov 2019 20:20

Thank you very much for your answers.
I'll try to get it working :)

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: Linux dedicated server

Post by MagicBuzz » 30 Nov 2019 10:31

I'm almost done, but I can't run the server.

I'm running with thins Linux version :

Code: Select all

Linux openttdsrv 4.19.0-6-arm64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) aarch64
I get this error :

Code: Select all

freebox@openttdsrv:~$ server/openttd -D -f
dbg: [net] Starting dedicated version 1.10.0-beta1
Loading dedicated server...
  - Forked to background with pid 30691
Unable to open logfile: No such file or directory
I took a look at the --help screen, but I don't see any mention to log file, so I don't know which folder or file I should create.
I also tried to run with sudo with no more success.

I also saw some error/warning messages during the previous steps ?

freebox@openttdsrv:~$ sudo apt-get build-dep openttd

Code: Select all

Setting up x11-common (1:7.7+19) ...
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
freebox@openttdsrv:~/server-source$ make bundle

Code: Select all

[SRC] Compiling cpu.cpp
/home/freebox/server-source/src/cpu.cpp:74:2: warning: #warning "(non-fatal) No support for rdtsc(), you won't be able to profile with TIC/TOC" [-Wcpp]
 #warning "(non-fatal) No support for rdtsc(), you won't be able to profile with TIC/TOC"
  ^~~~~~~
  

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: Linux dedicated server

Post by MagicBuzz » 30 Nov 2019 11:09

Eureka !

Without -f flag I got this error :

Code: Select all

freebox@openttdsrv:~$ server/openttd -D
dbg: [net] Starting dedicated version 1.10.0-beta1
dbg: [net] [core] starting network...
dbg: [net] [udp] initializing listeners
dbg: [net] [core] network online, multiplayer available
dbg: [net] Detected broadcast addresses:
dbg: [net] 0) 192.168.0.255
Error: Failed to find a graphics set. Please acquire a graphics set for OpenTTD. See section 4.1 of README.md.
Then I downloaded opengfx 0.5.5

Code: Select all

freebox@openttdsrv:~$ mkdir .openttd
freebox@openttdsrv:~$ mkdir .openttd/baseset
freebox@openttdsrv:~$ cd .openttd/baseset/
freebox@openttdsrv:~/server$ wget http://master.binaries.openttd.org/binaries/extra/opengfx/0.5.5/opengfx-0.5.5-all.zip
--2019-11-30 11:03:20--  http://master.binaries.openttd.org/binaries/extra/opengfx/0.5.5/opengfx-0.5.5-all.zip
Resolving master.binaries.openttd.org (master.binaries.openttd.org)... 2001:41d0:8:6fa6:1::2, 94.23.161.41
Connecting to master.binaries.openttd.org (master.binaries.openttd.org)|2001:41d0:8:6fa6:1::2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3548368 (3.4M) [application/zip]
Saving to: ‘opengfx-0.5.5-all.zip’

opengfx-0.5.5-all.zip         100%[=================================================>]   3.38M   511KB/s    in 6.8s

2019-11-30 11:03:27 (511 KB/s) - ‘opengfx-0.5.5-all.zip’ saved [3548368/3548368]

freebox@openttdsrv:~/.openttd/baseset$ sudo unzip opengfx-0.5.5-all.zip
Archive:  opengfx-0.5.5-all.zip
  inflating: opengfx-0.5.5.tar
freebox@openttdsrv:~/.openttd/baseset$ tar -xvf opengfx-0.5.5.tar
opengfx-0.5.5/
opengfx-0.5.5/ogfxt_toyland.grf
opengfx-0.5.5/ogfxe_extra.grf
opengfx-0.5.5/ogfxc_arctic.grf
opengfx-0.5.5/ogfx1_base.grf
opengfx-0.5.5/license.txt
opengfx-0.5.5/opengfx.obg
opengfx-0.5.5/readme.txt
opengfx-0.5.5/ogfxi_logos.grf
opengfx-0.5.5/changelog.txt
opengfx-0.5.5/ogfxh_tropical.grf
freebox@openttdsrv:~/.openttd/baseset$ rm *.zip
freebox@openttdsrv:~/.openttd/baseset$ rm *.tar
rm: remove write-protected regular file 'opengfx-0.5.5.tar'? y
freebox@openttdsrv:~/.openttd/baseset$ cd ..
freebox@openttdsrv:~/.openttd$ cd ..
freebox@openttdsrv:~$ server/openttd -D
dbg: [net] Starting dedicated version 1.10.0-beta1
dbg: [net] [core] starting network...
dbg: [net] [udp] initializing listeners
dbg: [net] [core] network online, multiplayer available
dbg: [net] Detected broadcast addresses:
dbg: [net] 0) 192.168.0.255
[2019-11-30 11:05:40] dbg: [net] [udp] closed listeners
[2019-11-30 11:05:40] dbg: [net] [udp] initializing listeners
[2019-11-30 11:05:40] dbg: [net] [udp] closed listeners
[2019-11-30 11:05:40] dbg: [net] [udp] initializing listeners
[2019-11-30 11:05:40] dbg: [net] starting listeners for clients
[2019-11-30 11:05:40] dbg: [net] [tcp] listening on IPv4 port 0.0.0.0:3979 (IPv4)
[2019-11-30 11:05:40] dbg: [net] [tcp] listening on IPv6 port [::]:3979 (IPv6)
[2019-11-30 11:05:40] dbg: [net] starting listeners for incoming server queries
[2019-11-30 11:05:40] dbg: [net] [udp] listening on IPv4 port 0.0.0.0:3979 (IPv4)
[2019-11-30 11:05:40] dbg: [net] [udp] listening on IPv6 port [::]:3979 (IPv6)
[2019-11-30 11:05:40] dbg: [net] Generating map, please wait...
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 5
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 10
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 15
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 20
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 25
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 30
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 35
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 40
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 45
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 50
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 55
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 60
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 65
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 70
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 75
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 80
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 85
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 90
[2019-11-30 11:05:40] dbg: [net] Map generation percentage complete: 99
[2019-11-30 11:05:40] dbg: [net] Map generated, starting game
Now, I can run the serveur.

But each time I set the "-f" flag I still get the error regarding log file :(

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4747
Joined: 09 Sep 2007 05:03
Location: home

Re: Linux dedicated server

Post by Alberth » 30 Nov 2019 16:36

A bit of digging:

Code: Select all

src/dedicated.cpp
15:FILE *_log_fd   = nullptr; ///< File to reroute output of a forked OpenTTD to
43:                     _log_fd = fopen(_log_file, "a");
44:                     if (_log_fd == nullptr) {
45:                             perror("Unable to open logfile");
So it tries to open the path in _log_file apparently, which gets set by

Code: Select all

src/fileio.cpp
1236:   extern char *_log_file;
1237:   _log_file = str_fmt("%sopenttd.log",  _personal_dir);
So do you have a writable personal directory? (see also the readme file that explains all the various directories that openttd has and where to find them)
It looks like it tries to write "openttd.log" there.

Readme may also explain about logfiles, not sure though.
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: Linux dedicated server

Post by MagicBuzz » 01 Dec 2019 08:51

Hello Alberth,

Do you know how is determined "_personal_dir" ?

When running DEBUG, I see that :

Code: Select all

freebox@openttdsrv:~$ sudo server/openttd -D -f -d 9
dbg: [misc] /home/freebox/ added as search path
dbg: [misc] /root/.local/share/openttd/ added as search path
dbg: [misc] /root/.openttd/ added as search path
dbg: [misc] /home/freebox/server/ added as search path
dbg: [misc] /usr/local/share/games/openttd/ added as search path
dbg: [misc] /root/.config/openttd/ found as config directory
dbg: [misc] /root/.local/share/openttd/ found as personal directory
dbg: [misc] Scanning for tars
dbg: [misc] Scan complete, found 0 files
dbg: [net] Starting dedicated version jgrpp-0.32.3
Loading dedicated server...
  - Forked to background with pid 691
Unable to open logfile: No such file or directory
freebox@openttdsrv:~$
Directory "/root/.local/share/openttd/" is owned by root I guest, and it doesn't to be wise granting openttd to write in it.

It looks like this folder is chosen at compile time... May I did compile it with sudo ?
Is there any way to change it ?

-- Edit :

When running "./configure --enable-dedicated" I get this :

Code: Select all

using CFLAGS... -O2 -fomit-frame-pointer  -Wall -Wno-multichar -Wsign-compare -Wundef -Wwrite-strings -Wpointer-arith -W -Wno-unused-parameter -Wredundant-decls -Wformat=2 -Wformat-security -Winit-self -fno-strict-aliasing -Wcast-qual -fno-strict-overflow -Wnon-virtual-dtor -Wno-free-nonheap-object -rdynamic -DUNIX -D_FORTIFY_SOURCE=2 -DWITH_DL -DWITH_DBG_GDB -DWITH_PRCTL_PT -g1 -DWITH_SIGACTION -DWITH_SIGALTSTACK -DWITH_BITMATH_BUILTINS -DWITH_DEMANGLE -DWITH_ZLIB   -DWITH_LIBLZMA   -DWITH_LZO -DWITH_XDG_BASEDIR   -D_SQ64 -I/home/freebox/jgrpp-sources/src/3rdparty/squirrel/include -DWITH_PNG -I/usr/include/libpng16  -DDEDICATED -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\".openttd\" -DGLOBAL_DATA_DIR=\"/usr/local/share/games/openttd\"
So it looks like to be the .configure script that set up the personal dir.
As you can see I run it without sudo.
And when compiling :

Code: Select all

freebox@openttdsrv:~/jgrpp-sources$ make bundle
make[1]: Entering directory '/home/freebox/jgrpp-sources/objs/lang'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/freebox/jgrpp-sources/objs/lang'
make[1]: Entering directory '/home/freebox/jgrpp-sources/objs/setting'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/freebox/jgrpp-sources/objs/setting'
make[1]: Entering directory '/home/freebox/jgrpp-sources/objs/extra_grf'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/freebox/jgrpp-sources/objs/extra_grf'
make[1]: Entering directory '/home/freebox/jgrpp-sources/objs/release'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/freebox/jgrpp-sources/objs/release'
[BUNDLE] Constructing bundle
freebox@openttdsrv:~/jgrpp-sources$
So nothing to be done, I guess I already compiled without sudo as I though...

PS : Here I'm compiling jgrpp but I also have the same problem with the openttd trunk.

User avatar
jfs
Director
Director
Posts: 607
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Linux dedicated server

Post by jfs » 01 Dec 2019 10:27

_personal_dir is determined from the home directory of the logged in used, via the xdgDataHome() function if XDG is available, and otherwise via the HOME environment variable. It's not set at compile time, but determined when you actually start the game.

Try setting HOME and XDG_DATA_HOME to some appropriate path while running, like this:

Code: Select all

HOME=/home/freebox/ottd-run XDG_DATA_HOME=/home/freebox/ottd-run server/openttd -D -f

User avatar
MagicBuzz
Tycoon
Tycoon
Posts: 1171
Joined: 15 Feb 2003 17:32
Location: Villefranche-sur-Saône, France

Re: Linux dedicated server

Post by MagicBuzz » 01 Dec 2019 11:06

Thank you very much !

I'm surprised it works by default in such complex directories rather than :
- directly in the folder containing the "openttd" binary
- in some path found in the config file

I had to create this directory in my home path :
~/.local/share/openttd

Then copy in ~/.local/share/openttd/baseset all the grf I had in the ~/server/baseset folder

I would have prefered to indicate the base folder was ~/server, but when I set HOME this folder, it tries to access ~/server/.local/share/openttd

And another strange thing : there is no problem accessing and creating the ~/.config/openttd directly to store config files.

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4747
Joined: 09 Sep 2007 05:03
Location: home

Re: Linux dedicated server

Post by Alberth » 01 Dec 2019 20:25

If you read the readme.txt file, everything about all the various kinds of directories is explained in full details.
There is nothing strange about it, it works as advertised.
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.

Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 6 guests