yeetzone / docker-dontstarvetogether

Dockerfile for building a Don't Starve Together dedicated server image.
https://go.yeet.zone/discord
MIT License
281 stars 51 forks source link

Persist the logs #7

Closed thasmo closed 8 years ago

thasmo commented 8 years ago

We need to find a way to also persist the server log /home/steam/.klei/DoNotStarveTogether/log.txt and the chat log /home/steam/.klei/DoNotStarveTogether/chat_log.txt.

thasmo commented 8 years ago

We need to persist the whole /home/steam/.klei/DoNotStarveTogether/ directory anyway, because DST writes all kinds of other data into it.

-rw-r--r-- 1 1000 1000   15 Jan  5 16:37 boot_modindex
-rw-r--r-- 1 1000 1000    0 Jan  5 17:05 chat_log.txt
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 client_temp/
-rw-r--r-- 1 1000 1000 8016 Jan  5 17:05 log.txt
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 mod_config_data/
-rw-r--r-- 1 1000 1000  307 Jan  5 16:37 modindex
-rw-r--r-- 1 1000 1000  511 Jan  5 16:03 profile
drwxr-xr-x 2 root root 4096 Jan  5 17:05 save/
-rw-r--r-- 1 1000 1000  424 Jan  5 16:03 saveindex
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 server_temp/
drwxr-xr-x 3 1000 1000 4096 Jan  5 16:03 session/
-rw-r--r-- 1 root root  848 Jan  5 17:05 settings.ini

Need to think about how this influences the settings.ini file which is written initially from the entrypoint script if it's not existing. Probably we won't have any problems, I guess.

BraisGabin commented 8 years ago

The problem here is that log.txt is cleand any time the server is restarted. Is that desirable? Can we create a better log with all the historic?

BraisGabin commented 8 years ago

And the log doesn't have neither any time reference. You don't know when the things happened.

thasmo commented 8 years ago

The log.txt comes from DST itself, it's how the game logs it's output. If we went more information, we probably need to use/develop a mod. But that's not the scope of this project.

BraisGabin commented 8 years ago
-rw-r--r-- 1 1000 1000   15 Jan  5 16:37 boot_modindex
-rw-r--r-- 1 1000 1000    0 Jan  5 17:05 chat_log.txt
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 client_temp/
-rw-r--r-- 1 1000 1000 8016 Jan  5 17:05 log.txt
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 mod_config_data/
-rw-r--r-- 1 1000 1000  307 Jan  5 16:37 modindex
-rw-r--r-- 1 1000 1000  511 Jan  5 16:03 profile
drwxr-xr-x 2 root root 4096 Jan  5 17:05 save/
-rw-r--r-- 1 1000 1000  424 Jan  5 16:03 saveindex
drwxr-xr-x 2 1000 1000 4096 Jan  5 16:03 server_temp/
drwxr-xr-x 3 1000 1000 4096 Jan  5 16:03 session/
-rw-r--r-- 1 root root  848 Jan  5 17:05 settings.ini

I think that this output you posted comes for a wrong configurations. You can check that the unknown files are files that are usually stored at save.

So we have:

I think that our problem here is how we are going to allow the user to configure their servers: settings, mods, mod settings, world...

BraisGabin commented 8 years ago
docker run --volume /home/user/config/overworld:/var/lib/dsta/server/DoNotStarveTogether/ \
    --volume overworld:/var/lib/dsta/server/DoNotStarveTogether/save/ [...]

Inside /home/user/config/overworld you have your desired config: the files settings.ini, worldgenoverride.lua and modoverrides.lua.

Because this is not "ready to play" the image must know how to generate three different configurations:

docker run --volume /home/user/config/overworld:/var/lib/dsta/server/DoNotStarveTogether/ dstacademy/server generateconfig
docker run --volume /home/user/config/overworld:/var/lib/dsta/server/DoNotStarveTogether/ dstacademy/server generateconfig --shard=12345
docker run --volume /home/user/config/overworld:/var/lib/dsta/server/DoNotStarveTogether/ dstacademy/server generateconfig --cave --shard=12345

And, if the user just start the container the entry point script checks that there is not any configuration so he launches the generateconfig by default and starts a server.

This way we have a ready to use, easy to config server. But it's easy to customize too because you have access to the files and you can edit them as you want. And if we finally make the web page the output will be this three files.

I know that this idea needs to be polish. But what do you think as a starting point? Any UX problem? Any technical problem?

thasmo commented 8 years ago

I appreciate the ideas, although we're gettin' off-topic I think.

So, persisting data from containers always involves volumes, at least as an easy, built-in option for Docker. Persisting the logs makes sense after all, if desired. That means, if one does not like to persist the files, no volumes should be configured for the containers.

After thinking about this, it probably makes total sense to change the pre-configured VOLUME to include the parent-directory of the save directory. The path would then be .klei/DoNotStarveTogether/, which includes save.

This will work from now on, because our entrypoint script does not overwrite existing files.

Additionally this enables people to just mount existing files, like settings.ini etc. to configure their server, if they don't want to use ENV variables.

Does that sound solid to you? We just change the default VOLUME path and document some examples.

We can think about how to configure the server via CLI in another ticket.

thasmo commented 8 years ago

By the way, we could incorporate #16 into this, so we can fix both in one change. :+1:

BraisGabin commented 8 years ago

It seems solid for me. You've conviced me about the environment variables. Or at least for a while ;-P.

If I continue thinking about my proposal I'll open a new issue.