mathielo / dst-dedicated-server

Don't Starve Together dedicated server guide for all platforms (Linux, Mac, Windows) with Docker. Extensive documentation covering mods installation, server config and performance, world generation and setting up admins.
MIT License
296 stars 56 forks source link

How to run it? #1

Closed grasses closed 6 years ago

grasses commented 6 years ago

When I build it, and after run command:

sudo docker run -it --name="dst" -p 10999:10999/udp -p 10998:10998/udp 1356c7564469

it return error:

[00:00:02]: [string "scripts/mainfunctions.lua"]:875: Unable to write to config directory. Please make sure you have permissions for your Klei save folder.
LUA ERROR stack traceback:
=[C]:-1 in (global) error (C) <-1--1>
scripts/knownerrors.lua:27 in (global) known_assert (Lua) <23-34>
   condition = false
   key = CONFIG_DIR_WRITE_PERMISSION
scripts/mainfunctions.lua:875 in () ? (Lua) <866-888>

[00:00:02]: [string "scripts/mainfunctions.lua"]:875: Unable to write to config directory. Please make sure you have permissions for your Klei save folder.
LUA ERROR stack traceback:
    =[C]:-1 in (global) error (C) <-1--1>
    scripts/knownerrors.lua:27 in (global) known_assert (Lua) <23-34>
    scripts/mainfunctions.lua:875 in () ? (Lua) <866-888>

[00:00:02]: Reset() returning
[00:00:02]: ... FilesExistAsyncThread complete
[00:00:03]: [200] Account Failed (6): "E_INVALID_TOKEN"
[00:00:03]: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[00:00:03]: !!!! Your Server Will Not Start !!!!
[00:00:03]: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[00:00:03]: No auth token could be found.
grasses commented 6 years ago

I try again using docker-compose, and find same error:

dst_master    | [00:00:03]: [CRITICAL] Failed to save file: /home/dst/.klei//DoNotStarveTogether/DSTWhalesCluster/Master/save/saveindex
dst_master    | [00:00:03]: [CRITICAL] Fingerprint:lhrjsjvnukdggkfltioqfhgigfnnnpeipdjlioijlhrjsjvnikdggkflhhoqfhgipgnnnpeijhjlioijkhrjsjvnxkdggkfluioqfhgiofnnnpeiddjlioijlhrjsjvntodggkflmkoqfhgiefnnnpeiifjlioijldrjsjvnijdggkflhjoqfhgipgnnnpeildjlioijgerjsjvnkjdggkflnioqfhgipinnnpeijdjlioijddrjsjvnjkdggkflmhoqfhgilfnnnpeipdjlioijgerjsjvntodggkflmkoqfhgiqinnnpeiogjlioijdcrjsjvnukdggkfljioqfhgihfnnnpeipdjlioijherjsjvnpmdggkfluioqfhgiognnnpeinejlioijaerjsjvnjkdggkflghoqfhgiejnnnpeihfjlioijfdrjsjvnpjdggkflmhoqfhgiofnnnpeimejlioijlhrjsjvnpjdggkfljioqfhgingnnnpeipdjlioijlhrjsjvnpjdggkfljioqfhgingnnnpeipdjlioijndrjsjvnskdggkflmioqfhgiofnnnpeicejlioij.
dst_master    | [00:00:03]: Collecting garbage...
mathielo commented 6 years ago

Hey @grasses , I've seen that permission issue happening before and it's most likely related to running docker through sudo.

A couple key points here: 1) Ideally, one shouldn't ever need to sudo in order to run docker containers. If you follow Docker's post-installation steps for Linux, you'll be able to manage docker with your non-root user.

:warning: Please do note that it might be necessary to start over after fixing your user permissions over docker as the sudo commands that were run could cause permissions conflicts, even after following that link above.

2) Using docker-compose up -d should suffice to run both containers (forest & caves) - no need to run complex docker run [...] with many arguments :)

If you want to change behaviour feel free to edit the docker-compose.yml to keep your startup command simple 🤓

Please do try this out and let me know the outcome. I will try to reproduce your issue by creating a new Linux machine and try running it with sudo to see if I can find any other simpler solution.

jankaszel commented 6 years ago

i ran into a similar issue, where my server wasn't able to access the volume. guessing it's related to the bound volume and its permissions? a simple chmod 777 on DSTClusterConfig and its sub-directories temporarily solved it for me, but there's better solutions. maybe introducing a distinctive user and applying chown could circumvent this?

mathielo commented 6 years ago

Hey @fallafeljan what OS are you using? Also, are you running docker by sudoing or directly with root user? If so it's the very same issue and fixing docker's user permissions should fix your issue.

jankaszel commented 6 years ago

i'm running the server on ubuntu 16.04. no sudo, simply docker-compose up -d. @grasses also used compose at the second attempt, so i guess we faced the same issue when the system tried to write onto the volume.

mathielo commented 6 years ago

Thanks for the feedback. Have you followed Manage Docker as a non-root user section in Post-installation steps for Linux? Just double-checking as I had it running on 2 different linux machines (both with Debian 9) without any problems.

Am spinning up an Ubuntu machine to see if it happens the same for me here.

jankaszel commented 6 years ago

no, i didn't explicitly followed that! the machine has been provisioned using docker-machine create, then i ssh'd into it. to be honest, i don't know if they adhere to the non-root principles... at least, i can run docker commands without sudo-ing!

mathielo commented 6 years ago

Alright I tried reproducing the issue without any luck. Here's what I did:

  1. Spun up a VM running Ubuntu Server 16.04 LTS
  2. Created a user mathielo and logged in
  3. Installed docker and did not followed the post-install (running docker with sudo on purpose)
  4. Cloned following the exact command from readme: cd ~ && git clone https://github.com/mathielo/dst-dedicated-server.git
  5. From /home/mathielo/dst-dedicated-server/ ran sudo docker-compose up (without -d to see the output).

It works, server spins up without any permissions issues.

mathielo@ubuntu ~/dst-dedicated-server (master) $ pwd                                                                                                                                                                                       ✗
/home/mathielo/dst-dedicated-server
mathielo@ubuntu ~/dst-dedicated-server (master) $ ls -lha DSTClusterConfig/Master                                                                                                                                                           ✗
total 56K
drwxrwxr-x 4 mathielo mathielo 4.0K Feb 13 11:12 ./
drwxrwxr-x 5 mathielo mathielo 4.0K Feb 13 11:12 ../
drwxr-xr-x 4 mathielo mathielo 4.0K Feb 13 10:39 backup/
drwxr-xr-x 7 mathielo mathielo 4.0K Feb 13 11:12 save/
-rw-rw-r-- 1 mathielo mathielo   43 Feb  2 11:18 .gitignore
-rw-rw-r-- 1 mathielo mathielo 2.6K Feb  2 11:18 leveldataoverride.lua
-rw-r--r-- 1 mathielo mathielo  461 Feb 13 11:12 modoverrides.lua
-rw-rw-r-- 1 mathielo mathielo  107 Feb  2 11:18 server.ini
-rw-r--r-- 1 mathielo mathielo    0 Feb 13 11:12 server_chat_log.txt
-rw-r--r-- 1 mathielo mathielo  22K Feb 13 11:18 server_log.txt
mathielo@ubuntu ~/dst-dedicated-server (master) $ ls -lha DSTClusterConfig/Master/save                                                                                                                                                      ✗
total 52K
drwxr-xr-x 7 mathielo mathielo 4.0K Feb 13 11:12 ./
drwxrwxr-x 4 mathielo mathielo 4.0K Feb 13 11:12 ../
drwxr-xr-x 2 mathielo mathielo 4.0K Feb 13 10:39 client_temp/
drwxr-xr-x 2 mathielo mathielo 4.0K Feb 13 10:39 forge_stats/
drwxr-xr-x 2 mathielo mathielo 4.0K Feb 13 10:39 mod_config_data/
drwxr-xr-x 2 mathielo mathielo 4.0K Feb 13 11:13 server_temp/
drwxr-xr-x 3 mathielo mathielo 4.0K Feb 13 11:13 session/
-rw-r--r-- 1 mathielo mathielo   15 Feb 13 11:12 boot_modindex
-rw-r--r-- 1 mathielo mathielo  139 Feb 13 11:13 modindex
-rw-r--r-- 1 mathielo mathielo  283 Feb 13 11:12 profile
-rw-r--r-- 1 mathielo mathielo  11K Feb 13 11:13 saveindex

All the files were created - and are owned by user mathielo even thought they were created via docker volume. No issues creating any files (backup/* save/*, server_log.txt, etc).


My guess would be that something odd happened when cloning the repo - maybe it was cloned with a different user, or a sudo git clone [...] perhaps? Then root would own the whole repo folder, creating permission issues for your regular user. Then it makes sense the chmod 777 fixes it.

@fallafeljan can you please double check what user owns the folders in your cloned repo, specially DSTClusterConfig onwards?


I'd say that @grasses had two issues:

sudo docker run -it --name="dst" -p 10999:10999/udp -p 10998:10998/udp 1356c7564469

This doesn't mount the volume required for the container to work; so it will fail as it won't find the folders within the container. The second one (when trying with docker-compose up I'd say is related to user permissions as explained above.

Please do come back with any feedback so we can work on improving the whole installation / setup flow for newcomers. Thanks!

jankaszel commented 6 years ago

thanks for all your efforts! (and your non-issue-related efforts in general, my server is running fine.) you're probably right and i connected the dots: i ssh'd into my machine as root and cloned the repository as root, too. docker, however, runs its processes with uid 1000 (maybe that's related to docker-machine?). in the end, it's just a plain permission issue.

i saw your commit with changes regarding the readme and your recommendations are totally fine. the issue i ran into (and @grasses too, probably) is more related to user management and less to this project.

mathielo commented 6 years ago

Cool :) Will close this issue then, hope the updates in readme will help preventing people from running into the same problem. Cheers!