jwestp / docker-supertuxkart

Docker image for deploying a SuperTuxKart server
GNU General Public License v3.0
14 stars 10 forks source link

Access network-console / Add AI-Karts / Add "server_config.log" to docker logs ? #7

Closed iluvatyr closed 3 years ago

iluvatyr commented 3 years ago

Sorry, this is a kind of nooby question. I was wondering how to add AI-Karts to the server so that there are always 2 AI Karts until 2 People joined so that there are gone. In the server_config.xml there is a following entry, which I set to true. But where do I set the number for the Bots?

    <!-- If true this server will auto add / remove AI connected with network-ai=x, which will kick N - 1 bot(s) where N is the number of human players. Only use this for non-GP racing server. -->
    <ai-handling value="true" />

Also, in the logs it shows following:

Wed May 26 17:06:12 2021 [info   ] STKHost: Host initialized.
Available command:

help, Print this.
quit, Shut down the server.
kickall, Kick all players out of STKHost.
kick #, kick # peer of STKHost.
kickban #, kick and ban # peer of STKHost.Wed May 26 17:06:12 2021 [info   ] STKHost: Server port is 2759
listpeers, List all peers with host ID and IP.
listban, List IP ban list of server.
speedstats, Show upload and download speed.

Where and how can I use these commands?

Additionally. is it possible to have the stuff that goes into "Supertux/root/.config/supertuxkart/config-0.10/server_config.log" to also go to the output of docker logs ? Why is it going to that location?

And as last: it possible to download all the addons automatically? I just used the addon folder from my Windows Supertux game and copied it into the location I mounted the server in.

THANKS A LOT!

jwestp commented 3 years ago

I was wondering how to add AI-Karts to the server so that there are always 2 AI Karts until 2 People joined so that there are gone.

Unfortunately there is no automated way of adding ai karts to the server. You can add them manually as described here.

Where and how can I use these commands?

I suppose this commands can be used when starting supertuxkart with the --network-console command line option which is not used in this docker image.

Additionally. is it possible to have the stuff that goes into "Supertux/root/.config/supertuxkart/config-0.10/server_config.log" to also go to the output of docker logs ? Why is it going to that location?

This seems to be the default location for this log file. It would be possible to redirect these logs to stdout which would require modifying the docker-entrypoint.sh. You could add this behaviour and submit a PR if you like.

And as last: it possible to download all the addons automatically?

This could also be done by modifying docker-entrypoint.sh. Feel free to submit a PR.

iluvatyr commented 3 years ago

Unfortunately there is no automated way of adding ai karts to the server. You can add them manually as described here.

I tried changing the docker-entrypoint.sh file by mounting it and then changing it to

#!/bin/bash
set -e
# Log in with username and password if given
if [ -n ${USERNAME} -a -n ${PASSWORD} ]
then
    supertuxkart --init-user --login=${USERNAME} --password=${PASSWORD}
fi

# Start the server
supertuxkart --server-config=server_config.xml
supertuxkart --connect-now=127.0.0.1:2759 --network-ai=2

but that didnt work to add AI-Karts. I wonder why. When I ran the command manually after the server started already, I was able to add AI via

docker exec <supertuxcontainer> supertuxkart --connect-now=127.0.0.1:2759 --network-ai=2 &

I suppose this commands can be used when starting supertuxkart with the --network-console command line option which is not used in this docker image.

I found that it works by also using: `docker exec -it supertuxkart --connect-now=127.0.0.1:2759 --network-console

I will have to read about how exactly the entrypoint works and also where and how supertuxkart implements the download of addons automatically so it would be possible to add this to the entrypoint. Maybe Ill add the request some time.

jwestp commented 3 years ago

When I ran the command manually after the server started already, I was able to add AI

I‘m glad you found a solution. 👍 Modifying the entry point that way did not work because the command supertuxkart --server-config=server_config.xml never terminates as long as the server is running. So the following command is never executed. You could try starting the server in the background by adding a & at the end of the line. I will also try if this works as expected.

I found that it works by also using: docker exec -it supertuxkart --connect-now=127.0.0.1:2759 --network-console

Good to know, I will add that to the README.

jwestp commented 3 years ago

Hi @Luca-Hummel,

ai karts can now be configured with the environment variable AI_KARTS. See the updated README for details.