Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

alainmcd

[HowTo] Run a Dedicated Server from your PC - without SteamCMD or the Dedicated Server Tool

Recommended Posts

alainmcd    888

If you want to host your own world and only be running when you're playing, just host a world from within the game. If you want to leave it running even when you're not playing so others can join, you DON'T need steamcmd or the dedicated server tool. Instead:

  1. Create a new world
    Spoiler

    Start DST normally. Go to the Host menu, create a new world in slot 5, customise your world with whatever settings and mods you like. Remember to add caves (press the "Add Caves" button in the World tab when creating your world). Once you get to the character selection screen, exit the game. Don't join the game just yet.

  2. Create a script to run your world
    Spoiler

    In Windows:

    Spoiler

    Go to your DST installation folder (in Steam, right-click Don't Starve Together -> Properties -> Local Files tab -> Browse Local Files). Go to "bin" and create a new file named RunDSTServer.bat with this content:

    
    
    cd /D "%~dp0"
    dontstarve_dedicated_server_nullrenderer.exe -only_update_server_mods
    start "My DST Server Master" dontstarve_dedicated_server_nullrenderer.exe -skip_update_server_mods -cluster Cluster_5 -shard Master
    start "My DST Server Caves"  dontstarve_dedicated_server_nullrenderer.exe -skip_update_server_mods -cluster Cluster_5 -shard Caves

    Make sure your file ends with ".bat" and not ".txt". Now create a desktop shortcut (right-click the file -> Send to -> Desktop (create shortcut).

    In Linux:

    Spoiler

    I rarely use Linux and I haven't actually tested it, so it might not work. Please do tell if it's the case.

    Copy and save the following text to "~/run_dst_servers.sh":

    
    
    #!/bin/bash
    
    install_dir="$HOME/.local/share/Steam/steamapps/common/Don't Starve Together"
    cluster_name="Cluster_5"
    
    cd "$install_dir/bin"
    
    run_shared=(./dontstarve_dedicated_server_nullrenderer)
    run_shared+=(-cluster "$cluster_name")
    run_shared+=(-monitor_parent_process $$)
    
    "${run_shared[@]}" -shard Caves  | sed 's/^/Caves:  /' &
    "${run_shared[@]}" -shard Master | sed 's/^/Master: /'
    

    (If it doesn't work, you can try this.)

    Give the script executable permissions by running the following command in a terminal:

    
    
    chmod u+x ~/run_dst_servers.sh

     

     

    In Mac:

    Spoiler

    I'm not a Mac user, so your computer might burst into flames it might not work at all. Feedback would be very appreciated.

    Copy and save the following text to a new file "~/run_dst_servers.sh":

    
    
    #!/bin/bash
    
    install_dir="~/Library/Application Support/Steam/SteamApps/common/Don't Starve Together"
    cluster_name="Cluster_5"
    
    cd "$install_dir/bin"
    
    run_shared=(./dontstarve_dedicated_server_nullrenderer)
    run_shared+=(-cluster "$cluster_name")
    run_shared+=(-monitor_parent_process $$)
    
    "${run_shared[@]}" -shard Caves  | sed 's/^/Caves:  /' &
    "${run_shared[@]}" -shard Master | sed 's/^/Master: /'
    

    Give the script executable permissions by running the following command in a terminal:

    
    
    chmod u+x ~/run_dst_servers.sh

     

     

     

     

  3. Profit!!
    Spoiler

    Run your script, start DST and join your world, it should be in LAN for you. Enjoy!

 

Notes:

  • No need to manually update your server with this method. The updates are handled by Steam.
  • This method should work in the public branch and the ANR beta, as well as any future beta as long as Klei don't make drastic changes to server setup.
  • Remember to close your world by typing "c_shutdown()" (without the quotation marks) in both windows, or you might lose some progress or worse. The server doesn't have to be empty.
  • You can, of course, use any other slot. Just remember to change your script in step accordingly, from Cluster_5 to whichever you want.
  • There's an issue with the cluster token expiring when trying to host through the batch file after hosting the same world from the game. See below how to fix it.
  • Similarly, you can hide the server from the Host Game menu by changing the cluster folder name (and your script accordingly). The benefit of having it show up in the game as a hostable world is that it makes it easier to manage mods, rollbacks and bans, however doing so while the world is running will probably have unintended consequences (losing progress or the whole world), so ONLY MANAGE YOUR SERVER WHILE THE SERVER ISN'T RUNNING. The benefits of hiding it are avoiding these accidents and having an extra save slot.
  • If you want to host several worlds at the same time, you'll have to manually edit the ports in the cluster.ini and server.ini files, as always. You can, however, host a world and at the same time play in a different one hosted by someone else.
  • It is possible to host a world in a different branch at the same time, but you will need to download the DST Dedicated Server tool and a bit of tweaking. Feel free to ask.

Help! E_INVALID_TOKEN or E_EXPIRED_TOKEN

Spoiler

Something went wrong. Fortunately, it's easy to solve.

  1. Generate a new token: Start DST and log in. Open the console, usually by pressing ~ (the key to the left of 1). If it doesn't work, go to Options -> Controls and change the binding for Debug Console, near the end. I suggest using the key to the left of 1 regardless of your keyboard layout, for convenience' sake. Type "TheNet:GenerateClusterToken()" (without the quotations) and press enter.
  2. Place the token in your cluster folder: Go to your DST settings folder. Windows:
    Spoiler
    
    
    (My) Documents\Klei\DoNotStarveTogether

    if you are in the main branch. For the ANR beta it's

    
    
    (My) Documents\Klei\DoNotStarveTogetherANewReignBeta

     

    Linux:

    Spoiler
    
    
    ~/.klei/DoNotStarveTogether

    if you are in the main branch. For the ANR beta it's

    
    
    ~/.klei/DoNotStarveTogetherANewReignBeta

    Files and folders starting with a period are hidden by default. To show them in your file browser press Ctrl-H in Nautilus (the Ubuntu default browser) or Alt-. in Dolphin.

    Mac:

    Spoiler
    
    
    ~/Documents/Klei/DoNotStarveTogether

    if you are in the main branch. For the ANR beta it's

    
    
    ~/Documents/Klei/DoNotStarveTogetherANewReignBeta

     

    Move the file cluster_token.txt to your cluster folder, which should be Cluster_5. Yes, you do want to overwrite the existing file. Done!

  3. Run your batch file and play!

 

If this doesn't work for you, please detail your OS, whether you're in the beta, the steps you followed, and what error messages you received.

Share this post


Link to post
Share on other sites
Wyrv    2

I was able to bring the server online, but the server will not start with my in-game configs. 
I tried to use other cluster, and a new game was created (despite the fact that I already had a game in that spot), which is okay if I was able to find the server.ini and cluster.ini and configure as I want.
Could you point me in the right direction?

PS.: I have the DST Dedicated Server Installed. I tried in that folder, and couldn't find anything either.

Besides all that, it's a really good idea. Very simple and straight forward. Thank you ;)

Share this post


Link to post
Share on other sites
alainmcd    888

I'd suggest verifying your game cache (right-click on Don't Starve Together in Steam -> Properties -> Local Files tab -> Verify integrity of game cache...) and disabling any world-gen mods if your settings aren't being applied to your world, since following these instructions you are, in fact, creating a new world from within the game as you would normally do to host a game.

You can create a world in any slot you want, but you'd have to change the script in step 2 accordingly (I've added a note about that).

cluster.ini is located in your cluster folder and there should be a server.ini in both the Caves and Master subdirectories. The cluster folder should be something like Documents\Klei\DoNotStarveTogether\Cluster_5, but the exact path depends on your OS, whether you're in the beta and the slot you're using

Share this post


Link to post
Share on other sites
Zombo    1

Thank you for the guide. But how can I change settings? For example, now the Server names are the same but one is Cave and the other one is Forest. If my friend accidentally clicked into the Cave world...you know..

Share this post


Link to post
Share on other sites
alainmcd    888

@Zombo, the individual servers (or "shards") aren't announced on the server list, the whole cluster is, which means your friend can't join directly the caves server.

You can change the cluster name and description by editing cluster.ini in your cluster folder, which should be something like Documents\Klei\DoNotStarveTogether\Cluster_5; the exact path depends on your OS, whether you're in the beta and the slot you're using.

Share this post


Link to post
Share on other sites
Wyrv    2

UPDATE: This works perfectly. I messed things up when making the first post, now it's okay. As I said, simple and straight forward. This is exactly what I've been looking for.
Thank you very much.

Cheers.

Share this post


Link to post
Share on other sites

So this has been working great, but I have found a problem that like after I play for awhile and then disconnect from the server but the commands are all still running, that I cannot rejoin because I cannot find the server? How do I fix this? 
Also where is the cluster folder located? I can't seem to find it anywhere in my klei folder?
Thank you!

Share this post


Link to post
Share on other sites
alainmcd    888

@CaptainGunnar, are you also having the E_EXPIRED_TOKEN error? I hadn't encountered until now. I'll try to investigate why it's happening. For now I can suggest you either briefly host the world through the game to renew the token or you generate a new token via TheNet:GenerateClusterToken() and place it in your cluster folder. Or just host the world normally, even though it completely defeats the point of this thread, but it's a fallback.

TheNet:GenerateClusterToken() generates a token in cluster_token.txt in your DST settings folder, which will be something like Documents\Klei\DoNotStarveTogether, the exact location depending on your OS and whether you're in the beta. You then have to move the file to your cluster folder, which is Cluster_5.

Also, welcome to the forums! And I hadn't noticed @Wyrv and @Zombo are also new here, sorry! Welcome to both of you too!

Share this post


Link to post
Share on other sites

@alainmcd Yeah that is what is coming up, but like the server is still running with other people on it, I just cannot find it to join again. Then it works again if I host the world normally then exit and run the bat file again. I will give the generating a new token a chance since I am going to play for awhile and I will let you know if that fixes it! So I will generate and move it then let you know.
Thanks for the reply and the welcome! And by the way this method is working great and is a lot easier than the others I've seen! :)

Do I put  TheNet:GenerateClusterToken() into the command prompt for the servers to generate the new token or where do I put it?

Share this post


Link to post
Share on other sites
alainmcd    888

@ProfFarnsworth, I haven't even tried to create a single-shard server this way!

(If you wanted to create a single-shard server, I'd recommend creating a world with caves and then editing the script to not run the slave. Hosted multi-shard worlds are effectively 2 dedicated servers running plus a client, which is what makes this method so simple, whereas single-shard hosted worlds are handled differently.)

Share this post


Link to post
Share on other sites
alainmcd    888

@ProfFarnsworth, if you mean running several clusters at the same time, you would follow the guide for the first world, rename its cluster folder, change your batch file accordingly and edit the ports in your cluster.ini and both server.ini files, then create the second world. I can give more detailed instructions if you want (or anyone else).

However, if you mean running a cluster with more than 2 shards (say, an overworld and two caves, or three overworlds or whatever), it's... possible, I guess. Create a world following the guide. Go to your cluster folder, copy and paste the Caves folder, rename the new folder Caves2, edit its server.ini to change the server_port so it doesn't clash with your other slave (add 1 or 2 to the server_port and you should be OK), change leveldataoverride.lua and modoverrides.lua as desired (for example, if you want the third level to be another overworld, copy the leveldataoverride.lua from your Master and overwrite the one in this folder; you can also import different configurations by creating a new world from within the game and copying its files, or you can manually edit them), and delete the "save" folder (if you don't, you'll have two caves levels with identical layout). Add a line to your batch file so that it runs this third shard too.

Spoiler

In Windows, add this as the last line:


start "My DST Server Caves2"  dontstarve_dedicated_server_nullrenderer.exe -skip_update_server_mods -console -cluster Cluster_5 -shard Caves2

In Linux and Mac, add this line right before the last one:


"${run_shared[@]}" -shard Caves2 | sed 's/^/Caves2: /' &

 

And you should have all three shards running at the same time. (Again, I can be clearer and more detailed if needed.) But here's the problem: the portals wouldn't link properly. The overworld portals would, I think, be randomly linked to either caves' portals. You would have to manually link the portals and generate new ones as needed. There's this mod which should help, but I haven't tried it myself.

Do let me know if you need more info or if I still haven't answered your question. :p

Share this post


Link to post
Share on other sites
alainmcd    888

@CaptainGunnar, I'm very sorry, I missed your last question and didn't read it until now. I really hope you found the answer in the meantime; I added the "Help!" section to explain how to solve the issue. Turns out the token expires after hosting the world from within the game for some reason, and you need to generate a new one.

Share this post


Link to post
Share on other sites
UnderwearApp    134

@alainmcd, Thank you for the very detailed and informative response. I have actually used that mod before and am still subbed so I will give this a try. I am interested to see if the second cave would generate only when you entered it and whether it would sync up with the overworld seasons. Thanks again!

Share this post


Link to post
Share on other sites
alainmcd    888

The second cave should be generated upon starting the shard. I would assume time of day and seasons are synched with the master, but now that you mention it, I don't know for sure.

Share this post


Link to post
Share on other sites
Vegatrone    1

i hosted my server without beta with your guide above , but i do want to know how to add ANR beta to it , i tried to add to the RUNDSTSERVER.bat  in the first line this >>>  -beta anewreignbeta 

but when i run , i get invalid token and mods wont load , so when that happened , i tried generating a new token and replacing the existing ones :

Cluster_1 in DST Folder
Cluster_5 in DST Folder

&

Cluster_1 in DST ANR  Folder

, also i got that MyDediServer suddenty within DST ANR Folder 

,also i got frustrated and tried to replace the whole DST ANR folder with normal folder ( i know is messed up , but meh .. )

now Mods load but still token error ...

is there anyway i can host with ANR and without errors , and can u please show me what folders and files should i have in the ANR folder cuz i ruined everything lol :))

Share this post


Link to post
Share on other sites
alainmcd    888

Hi @Vegatrone, welcome to the forums!

Actually, copying everything from the DST folder to the ANR folder is what I'd recommend. To jump into the beta you should only need two steps (extra detailed instructions in case anyone else is interested):

  1. Opt into the beta through Steam: right-click on DST -> Properties -> Betas tab -> select "anewreignbeta - A New Reign public beta" from the dropdown menu and finally press the "Close" button.
  2. Copy your DST settings folder and make it available in the beta: Go to (My) Documents\Klei, copy DoNotStarveTogether, paste it in the same folder and rename the new folder to DoNotStarveTogetherANewReignBeta. Better to copy the whole folder instead of just renaming it, this way we have a backup just in case.

Which is pretty much all you'd do to play in the beta in any case. You don't need to edit your batch file or any other file or worry about moving folders and all that. (The "-beta" parameter you mention is only needed in the SteamCMD installation, to tell SteamCMD to update the game from the beta branch. You don't need it since the updates and betas are handled by the Steam client.) Mods should work normally.

The only folder you must have in the ANR folder is the one with your server, which would be Cluster_5 unless you used a different one, but it doesn't hurt to import everything (and everything should work OK), hence copying the whole folder. If you're having errors with your token, check out the steps to solve it in the spoiler under  Help! E_INVALID_TOKEN or E_EXPIRED_TOKEN in the OP.

Hope this helps you! Don't hesitate to ask if you need any more help.

Share this post


Link to post
Share on other sites
Rily    552

Thanks, I was using this method since the game allows caves in hosted games, but I can't update it, why?, how can I update it from steamcmd?, Im on the ANR beta branch

Share this post


Link to post
Share on other sites
alainmcd    888

@Rily, I'm not sure what you mean, if you're using this method you don't need SteamCMD or the DST Dedicated Server tool, you're only using the files included with the DST app, and updates are handled by the Steam client. If your game isn't updating, try restarting Steam. You can't update the game through SteamCMD (I lie, you can, but it'd probably be pointless to even try).

Share this post


Link to post
Share on other sites
Rily    552
3 hours ago, alainmcd said:

@Rily, I'm not sure what you mean, if you're using this method you don't need SteamCMD or the DST Dedicated Server tool, you're only using the files included with the DST app, and updates are handled by the Steam client. If your game isn't updating, try restarting Steam. You can't update the game through SteamCMD (I lie, you can, but it'd probably be pointless to even try).

sorry, I should explain me better, I used this method when I hosted from the same pc, I forgot to explain that now I only create the files and use steamcmd to host from another pc with that generated world, I would like to test this from another pc but for now I want to know how to update the game with steamcmd, I think that I need a command, I heard about it but the last one doesn't work, actually I need to update the game and even the mods from the pc where I play and I literally copy all the files to the host pc

Share this post


Link to post
Share on other sites
Rily    552
On 12/1/2017 at 7:15 AM, alainmcd said:

From the Dedicated Server Quick Setup Guide:


c:\steamcmd\steamcmd.exe +login anonymous +app_update 343050 validate +quit

This thread is about setting up and running dedicated servers without SteamCMD or the Dedicated Server tool, though.

sorry, I was looking for that command, I thought that here someone could help because I didn't find answers in that thread, and that command doesn't work for me, thanks anyways

Share this post


Link to post
Share on other sites
Vegatrone    1
On 1/11/2017 at 7:49 PM, alainmcd said:

Hi @Vegatrone, welcome to the forums!

Actually, copying everything from the DST folder to the ANR folder is what I'd recommend. To jump into the beta you should only need two steps (extra detailed instructions in case anyone else is interested):

  1. Opt into the beta through Steam: right-click on DST -> Properties -> Betas tab -> select "anewreignbeta - A New Reign public beta" from the dropdown menu and finally press the "Close" button.
  2. Copy your DST settings folder and make it available in the beta: Go to (My) Documents\Klei, copy DoNotStarveTogether, paste it in the same folder and rename the new folder to DoNotStarveTogetherANewReignBeta. Better to copy the whole folder instead of just renaming it, this way we have a backup just in case.

Which is pretty much all you'd do to play in the beta in any case. You don't need to edit your batch file or any other file or worry about moving folders and all that. (The "-beta" parameter you mention is only needed in the SteamCMD installation, to tell SteamCMD to update the game from the beta branch. You don't need it since the updates and betas are handled by the Steam client.) Mods should work normally.

The only folder you must have in the ANR folder is the one with your server, which would be Cluster_5 unless you used a different one, but it doesn't hurt to import everything (and everything should work OK), hence copying the whole folder. If you're having errors with your token, check out the steps to solve it in the spoiler under  Help! E_INVALID_TOKEN or E_EXPIRED_TOKEN in the OP.

Hope this helps you! Don't hesitate to ask if you need any more help.

Thanks for the reply , i solved it somehow , and it is playable so far with caves and stuff :p

Share this post


Link to post
Share on other sites