Managing Chivalry on Linux server



  • Hi all, I’ve just set up the dedicated server on a Linux box and so far, it’s mostly going great. However, I do have a slight problem. Every now and then the software seems to crash for some reason - I’m still trying to work out why, but in the meantime it’s a little bit annoying as if I’m not around to restart it, then nobody can play on the server until I’m home/not busy.

    Does anybody have a script that they use to keep an eye on the process and restart if it fails? Preferably one that works with multiple instances running at the same time. If not, are there any other tricks to sorting the problem?

    Any help would be appreciated. :)



  • Isn’t this refreshing to see a post about Linux for a change. Why not run it only when your at home. Or I’d suggest you
    get windows and you can work in peace of mind knowing it won’t crash.



  • @loin:

    Isn’t this refreshing to see a post about Linux for a change. Why not run it only when your at home. Or I’d suggest you
    get windows and you can work in peace of mind knowing it won’t crash.

    The reason I don’t only run it when I’m at home is that a lot of people enjoy playing on the server at times when I’m not there. Given that it’s as much for their benefit as my own, it seems silly to aim for having it running only some of the time. Whilst I would have preferred to run the Chivalry server on Windows, I only have a Linux box available (and it needs to remain a Linux box for the other tasks it performs).

    Anyway, during some down time earlier I put this together. I’m pretty sure it’s only just up to the task, but it seems to work so far. My bash skills are awful. :/

    #!/bin/bash
    
    PIDFILE="s1.pid"
    LOGFILE="s1.log"
    PORT=7777
    QPORT=27220
    PLAYERS=24
    STARTMAP="AOCFFA-Arena3_P"
    CONFDIR="server1"
    CHIVDIR="/home/steam/steamgames/chivalryserver/Binaries/Win32"
    
    # Remove old pid file before starting.
    if [ -e $PIDFILE ] ; then
        rm $PIDFILE
    fi
    
    while true
    do
        if [ -e $PIDFILE ] ; then
            pid=$(head -n 1 $PIDFILE)
            if ! ps -p $pid > /dev/null ; then
                echo -e "[\e[31mFAIL\e[39m]] $(date +'%T') :: Server down. Restarting..."
                cd $CHIVDIR
                wine UDK.exe $STARTMAP?steamsockets -dedicated=true \
                    -seekfreeloadingserver -port=$PORT -QueryPort=$PORT \
                    -maxplayers=$PLAYERS -configsubdir=$CONFDIR &> $LOGFILE &
                cd ~
    
                if [ $? -eq "0" ] ; then
                    echo -e "[ \e[32mOK\e[39m ] $(date +'%T') :: Server restarted."
                    echo $! > $PIDFILE
                else
                    echo -e "[\e[31mFAIL\e[39m]] $(date +'%T') :: Server could not start. Exit code: $?"
                fi
            fi
        else
            echo -e "[WAIT] $(date +'%Y/%m/%d %T') :: Starting server."
            cd $CHIVDIR
            wine UDK.exe $STARTMAP?steamsockets -dedicated=true \
                -seekfreeloadingserver -port=7777 -QueryPort=27220 \
                -maxplayers=24 -configsubdir=server1 &> $LOGFILE &
            cd ~
    
            if [ $? -eq "0" ] ; then
                echo -e "[ \e[32mOK\e[39m ] $(date +'%T') :: Server started."
                echo $! > $PIDFILE
            else
                echo -e "[\e[31mFAIL\e[39m]] $(date +'%T') :: Server could not start. Exit code: $?"
            fi
        fi
    
        sleep 10m
    done
    

    That at least solves this particular issue, for now anyway.



  • I am no expert but don’t the chivalry ports work best 1 number apart like 7778 and 7779 for example. Also you might
    have a syntax error in your code , all it takes is a comma missed or wrongly placed, even another symbol mispel.
    what about a post condition, do they have a case function in that stuff your using?



  • As far as I can tell, the syntax itself is fine is fine (if you’ve seen anything in particular, please let me know - at the moment though everything seems to run fine). However, there is definitely a problem with the way that the program is being launched. Basically, by redirecting output from UDK.exe to a log file, it causes wineconsole to launch and hog the CPU at 100%; running without a log file works normally, but script messages get a little lost amongst everything else. I’ll edit the script above to remove it, in case anyone ever plans on making use of it.

    I’m pretty sure that bash does have a case statement, but I wasn’t really planning on doing anything else with this as I’m looking for a much more robust solution now, whether one that’s already been created or one that I end up making myself. I already had plans to put together a little RCon tool, so maybe I could integrate it with that.

    In terms of the ports, I’m not sure. I didn’t think it made a difference, but I’ll have a look around to see if it there’s any truth in that (to get this up and running, I just looked at a few examples of what other people were doing with their port/query port setting and a lot of them have the former in the 7000s and the latter in the 27000s).

    What I’ve learned from this experience so far is that running Chivalry on Linux is not as smooth a process as I thought it was after getting it running at the first attempt. :P



  • This Rcon thingy is on this site some were. They do have some kind of thing it was written. Just out of interest what do
    you think the server hosts use? just ask them for assistance if its linux let us know.



  • @loin:

    This Rcon thingy is on this site some were. They do have some kind of thing it was written. Just out of interest what do
    you think the server hosts use? just ask them for assistance if its linux let us know.

    Most seem to be using windows vm’s (although not sure what proportion of the vm hosts are windows or esx etc)



  • My server host uses Linux, its flawless. They are gameservers.com on their forums they might have your issue. linux has always been an excellent choice for gaming on all my servers.


Log in to reply