News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

How to set-up (or compile) a Linux headless Simutrans server?

Started by edwin_fox, October 21, 2024, 03:24:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

edwin_fox

Hallo people :)

I finally managed to assemble a humble PC for hosting some lightweight games I enjoy playing with friends - and now I really wish to host a 24/7 Simutrans server using some maps I gathered.

Problem is, I cannot host it 'headless' - or, I couldn't find any information online on how to run the game instance without the game interface (with just a running terminal). Running the server with the client interface wouldn't do, because it would take up video memory and my modest server wouldn't handle it...

So, where can I find a guide, or manual, or some guidance on making Simutrans run headless? Do I have to compile it, and if so, are there any flags I should use for compiling?

In other news: my aim is a cooperative server, emulating some historical scenarios such as the evolution of transport in the US, Europe, Americas... I heavily edit the maps so that I add mid and long-term goalposts to players. I would love to see people from the community playing with us, as soon as I can run the headless server! :)

I speak Portuguese, also fluent in EN, DE, ES. Thank you! 

Roboron

You need to compile a headless version of Simutrans https://simutrans-germany.com/wiki/wiki/en_CompilingSimutrans

Compiling with CMake, on the "generate build files" step, run:

cmake -DCMAKE_BUILD_TYPE=Release -DSIMUTRANS_BACKEND=none -B build .
After compiling, run Simutrans with arguments:

./simutrans -server [port] -objects [pakset] -log -singleuser -debug 2 -server_admin_pw [password] -announce -pause -server_dns [IP] -server_name [server name] -load [savegame-name.sve]
Set arguments as necessary/desired.

edwin_fox

Thank you so much Roboron, you're awesome as always! <3

prissi

I think it would be better to name the cmake backend "posix", as it does a posix build ... You can also compile with backend=posix with the makefile.

edwin_fox

Thanks again people, I was able to compile it - I tried using backend=posix, but it returned an error (can't remember the message now) so I went on with backend=none and it worked

I also specified the revision and number of cores - I'll post them here for anyone who's also wishing to the same

cmake -LH <path where the src is>
cmake -DCMAKE_BUILD_TYPE=Release -DSIMUTRANS_USE_REVISION=<desired revision number, ie. r11400> -DSIMUTRANS_BACKEND=none -B build <path where the src is>
cmake --build build -j 4

Also, I have another doubt - since it's a headless server, how do I save the game? I see an option in simuconf.tab (server_save_game_on_quit = 1) but is there any other way - a command for the headless terminal?

prissi

First, please use the revision number of the revision you have checked out, otherwise people cannot stay connected as the internal game state changes with revisions. The easiest way to make sure that you have the right revision is using the svn server to get the code.

The number of cores will just speed up your build. The only speedup for that on a server is for loading and saving though, and not using more than two cores. Even more, my vserver is single core and loads faster than a typical client, because it does not have to recalculate all the graphics. So headless multicore servers with more than two cores bring no speedup.

If you have a single core vserver, compile without threads. The cmake option is "SIMUTRANS_MULTI_THREAD=0" to switch off threading.

Roboron

Quote from: edwin_fox on November 01, 2024, 07:45:57 AMAlso, I have another doubt - since it's a headless server, how do I save the game? I see an option in simuconf.tab (server_save_game_on_quit = 1) but is there any other way - a command for the headless terminal?

Apart from save on quit, there's also the autosave option.

Andarix

I can't say to what extent automatic saving works on servers. I have the feeling that it doesn't work on my server.

Every client connection is saved. Unfortunately only when connecting. It is not saved when leaving.

To ensure that the data is saved up to date, you should reconnect briefly after leaving. Then the last map status is on the server and on the client.