Source Dedicated Server

Nov 9, 2012
Source Dedicated Server
  • Introduction

    The Source Dedicated Server is Valve's software for running any game server that uses the Source Engine. It is often abbreviated as HLDS. Setting it up is pretty simple, it gets complicated once you start adding in mods and custom configurations, however. Following is a guide on how the base TF2 installation is set up on GlaDoS.


    Getting the Steam Updater

    First we want to be in our home directory:
    Code:
    cd~
    Then we need to get the Steam Updater which is used to install and update servers:
    Code:
    wget http://storefront.steampowered.com/download/hldsupdatetool.bin
    Next we want to make this .bin file executable and run it:
    Code:
    chmod +x hldsupdatetool.bin
    ./hldsupdatetool.bin
    This will have created an executable called 'steam'. We now need to make 'steam' executable and run it to get the full Steam Updater:
    Code:
    chmod +x steam
    ./steam

    Management of Different Source Games

    HLDS is not a very well designed system in practice. It is messy and confusing at times. One of the most annoying issues is you cannot have two instances of the same game installed to a single installation of HLDS (i.e. you can't have two installations of TF2). To handle this, you simply install multiple versions of HLDS. To keep things nice and clean on GlaDoS, every game has its own installation. For example our home directory might look like this:
    As you can see above, there are two installations of tf2 - one for prophunt and one for a regular server.


    Installing an HLDS Game

    In this example we are going to be installing a regular server of TF2. To comply with what was just said above with folder naming conventions, let's make a folder called tf2-main:
    Code:
    mkdir tf2-main
    Now we can use the steam executable to install TF2 itself:
    Code:
    ./steam -command update -game "tf" -dir "tf2-main"
    To quickly analyse the above command - we are telling the steam updater that we want to install the game 'tf' (see here for full list of server names: https://developer.valvesoftware.com/wiki/Dedicated_Server_Name_Enumeration) and that we want to install it into the directory 'tf2-main'. The console will now spool out loads of information as it updates. Be prepared for this to take a fair amount of time.


    Starting and Stopping Source Servers

    Source servers are started using the srcds_run file. In the filesystem outlined above, it would be located at ~/tf2-main/orangebox/srcds_run. To just simply run the server you can type the following:
    Code:
     ./tf2-main/orangebox/srcds_run -game tf
    The issue with this is that you cannot 'minimize' the server whilst it is running and go and do something else. If you close the window, it will kill the server instance. To get around this we use screens. Read more here: http://linux.die.net/man/1/screen
    As well as screens we also use something called taskset when running the game servers. This allows you to bind the server to a single core on the CPU, meaning you can spread the load out across the processor and other games won't interfere. It is a good idea to make sure you don't have multiple games running on one core unless absolutely necessary.
    With screens and taskset added, our launch command now looks like this:
    Code:
     screen -A -m -d -S tf2-main taskset -c 0 ./orangebox/srcds_run -game tf +map pl_upward +maxplayers 19 +ip 158.125.100.3 +exec server-default.cfg -autoupdate -verify_all
    A few options have been added on specific to the server - they should be fairly self explanatory.
    Put this command in a file inside the tf2-main folder:
    Code:
    cd ~/tf2-main
    vim tf2-main.sh
    <paste command into file and save>
    chmod +x tf2-main.sh
    You can now run the server by simply executing the shell file:
    Code:
    ./tf2-main.sh
    To view the server console whilst it is running, type:
    Code:
    screen -r tf2-main
    To detach from it, press ctrl + a + d. If you are attached to a screen, nobody else can attach to it until you detach.
    You can list running screens by typing
    Code:
    screen -ls
    To stop the server, reattach to it and press ctrl + c


    Config File Trivia

    Config files for source servers can be very painful to setup and configure. It gets most complicated when you want to have multiple configs available server installation.
    In relation to our file system outlined above, configs are located in ~/tf2-main/orangebox/tf/cfg/. By default, the Source Server will look for server.cfg in this folder when it is run. If this is present it will be run, regardless of whether you put +exec in the startup. This is obviously going to be an issue if you want to run different configurations. To get around this, do not call any config files server.cfg, and make sure to use +exec in the server start command to specify a new one. You will note in the section above that server-default.cfg is used.



    Basic Config Files

    Config files differ between different Source Servers. TF2 is very different to L4D2 - they are not interchangeable in any way. For TF2 you can find the configuration options here: http://tf2wiki.net/wiki/Dedicated_server_configuration .
explosivose likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice