HOWTO: Linux LAN Dedicated Server

Discussion in 'Planetary Annihilation General Discussion' started by ollic, October 23, 2014.

  1. ollic

    ollic New Member

    Messages:
    10
    Likes Received:
    9
    Hi everybody!

    I just installed a dedicated server on Debian Jessie for a LAN party and i thought maybe someone
    wants to know how to do this.
    I used some Infos from the other thread here in the mods section and cut out the pastats/mods part (since its used for LAN only) and debianized it :)

    Whenever you see a # before the command it means to execute it as root. When you see a $ it means run as your normal user.

    Let's start with some packages that needs to be installed:
    # apt-get install mercurial golang libgl1-mesa-glx

    On your user account let's make a directory for PA and get papatcher to download the game:
    $ cd
    $ mkdir pa
    $ cd pa
    $ hg clone h t t p s://bitbucket.org/papatcher/papatcher
    $ go run papatcher/papatcher.go


    Enter your Uber account name/passwort and the game will download.
    I made a small startscript to quickly change the servername or parameters if needed. Paste it into a new file:
    $ nano run_server
    Code:
    #!/bin/bash
    
    PA_NAME="PA Titty Twister"
    PA_PATH="~/.local/Uber Entertainment/Planetary Annihilation/stable"
    
    exec "$PA_PATH"/server --headless --game-mode config --allow-lan \
    --server-name "$PA_NAME"
    exit 0
    
    $ chmod +x run_server

    This would be it. :)
    You can test if the server starts with:
    $ ./run_server

    Now comes the fun part! Since you want it to run even when you disconnect your ssh session and
    it also should auto restart on crash/exit you need something more. Alot of people use screen/byobu/tmux or nohup for this. But since Debian has the awesome systemd init system you can use this to keep your server running. :)

    We use the systemd user mode. This way you can start/stop/restart your server and see the logs without root.

    Install the service file:
    $ cd
    $ mkdir -p .config/systemd/user

    Paste this into the file and replace <user> with your user account name:
    $ nano .config/systemd/user/pa.service
    Code:
    [Unit]
    Description=Planetary Annihilation Dedicated Server
    
    [Service]
    Restart=always
    ExecStart=/home/<user>/pa/run_server
    
    [Install]
    WantedBy=default.target
    

    Let the systemd user instance run even if not logged in. Again replace <user>. Run as root:
    # loginctl enable-linger <user>
    Add your user to the systemd journal group to see logs:
    # adduser <user> systemd-journal

    Ok. Now its really over ;-)

    Start your server with:
    $ systemctl --user start pa.service
    Stop your server with:
    $ systemctl --user stop pa.service
    Restart your server with:
    $ systemctl --user restart pa.service

    See the status of your server with:
    $ systemctl --user status pa.service
    Code:
    $ systemctl --user status pa.service
    ● pa.service - Planetary Annihilation Dedicated Server
       Loaded: loaded (/home/server/.config/systemd/user/pa.service; enabled)
       Active: active (running) since Do 2014-10-23 20:30:50 CEST; 41s ago
    Main PID: 9346 (server)
       CGroup: /user.slice/user-1002.slice/user@1002.service/pa.service
               └─9346 ~/.local/Uber Entertainment/Planetary Annihilation/stable/server --headless --gam...
    
    Okt 23 20:30:50 Viki systemd[5119]: Started Planetary Annihilation Dedicated Server.
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.536] INFO Setting STEAM_RUNTIME to /home/serve...time
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.536] INFO SDL: Built w/ v2.0.3, linked w/ v2.0.3
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.537] INFO Loaded buildID 2014101573939
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.537] WARN Crash reporting disabled.
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.537] INFO Starting background thread pool with...eads
    Okt 23 20:30:50 Viki run_server[9346]: [20:30:50.537] INFO GameServerImpl::resetModUpdateAuthTo...e1f"
    Hint: Some lines were ellipsized, use -l to show in full.
    
    It will be restartet on every type of crash or normal exit. If no players are connected it seems to exit itself after 5 minutes. systemd will restart it then.

    If you want to see the output of the server while playing you can look into the journal in follow mode:
    $ journalctl -f --user-unit pa.service

    Thats it! Have fun!
    Last edited: October 23, 2014
  2. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    MMMMMHH YUMMY
    squishypon3 and SolitaryCheese like this.
  3. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    PA server on linux?!?
    [​IMG]
    Sticky this in the linux support subforum plz someone (but also keep it here)!
  4. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    All dedicated servers from the community I know of are running on linux.
    squishypon3 and SolitaryCheese like this.
  5. ollic

    ollic New Member

    Messages:
    10
    Likes Received:
    9
    Of course. Who wants to run a server on windows. :p

    Btw...missed something:

    Enable to start on boot:
    $ systemctl --user enable pa.service
    Disable start on boot:
    $ systemctl --user disable pa.service

    cola_colin likes this.
  6. icycalm

    icycalm Post Master General

    Messages:
    951
    Likes Received:
    722
    Can someone answer two questions for me?

    1. Why is Linux better than Windows for running the server?

    2. If PA was not developed for Linux, would the server still be running on Linux?
  7. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    Linux does not use resources for it's OS like Windows does. No offence, but my best friends brother, he has trouble reading, and he is taking computer work classes, and his linux test had that as a question. What are the practical benefits of Linux? Linux can allot more of the system resources on a server or large program or process, because it takes less resources to run the main screen on idle instead.

    And of course not, if it don't run on linux and uses windows libraries like directx, then it won't run on linux. The server might since it less likely needs directx to just run the server. However, the point of programming things to run on linux, is because people using windows are only doing so for popularity. Deciding to use Windows is like deciding the ideal weight is 90 lbs. Because it isn't. That is just what people insist.
    Last edited: October 24, 2014
    shiwanabe likes this.
  8. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    1. Seeing as how the limiting factor for PA appears to be the single thread CPU performance I really doubt it matters which OS you use. I'd say you should host on whichever OS you're more comfortable administering. I span up a Linux virtual server because it was cheaper per hour than a Windows one.

    2. Only if the server component had been developed for Linux.
    Last edited: October 24, 2014
    icycalm likes this.
  9. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,356
    Windows uses quite a bit more resources than Linux, most servers of ANY game or website are run on Linux machines.
  10. Quitch

    Quitch Post Master General

    Messages:
    5,850
    Likes Received:
    6,045
    He said the server, not servers in general. The reasons for the popularity of Linux in the cloud market are many and complex, and have nothing to do with which is best for PA. Hourly cost is far more relevant, as is your ability to administer it in the first place.
  11. ollic

    ollic New Member

    Messages:
    10
    Likes Received:
    9
    The Update Procedure

    Stop your server:
    $ systemctl --user stop pa

    Update the papatcher tool:
    $ cd
    $ cd pa/papatcher/
    $ hg pull
    $ hg update


    Update the pa game files:
    $ go run papatcher.go -update-only

    Start your server again:
    $ systemctl --user start pa

Share This Page