Automatic Updates

devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
edited February 2012 in Modding
<div class="IPBDescription">For your server</div>This tool will automatically keep a NS2 server update to date. It will query for an update every 5 minutes, and if one is found will kill the server and start HldsUpdateTool. It also provides an optional web UI, where you can view your server's log, execute rcon commands, and view player information.

FEATURES:
* Automatic updates
* Automatic restart on crash
* Server logs archived
* Performance graphs (cpu, memory, tickrate, players)
* Server remote control (view server log, players, chat remotely. Send rcon commands and see the server's response)

INSTALLATION:
1) Grab all the files from your dist/ directory, and upload them to your server (they should go in the same directory as your existing Server.exe binary).
2) In whatever script you use to start the server, replace 'Server.exe' with 'ns2update.exe'. (If you don't use a script, just start ns2update.exe instead of Server.exe)
3) (not required) Apply this registry tweak so memory read errors don't hang the server: <a href="http://www.zhacks.com/2010/04/10/disable-application-error-memory-could-not-be-read-popup/" target="_blank">http://www.zhacks.com/2010/04/10/disable-a...-be-read-popup/</a> . If you choose not to apply this, it's possible for your server to crash and not be automatically updated.

Once the tool is running, it will automatically start your server up, then check for updates every 5 minutes. It will check that the server is still running every 5 seconds, and restart it if it has crashed.

Every 5 minutes the cpu/memory/tickrate/players will be recorded and a graph generated. This graph will be saved to ns2server.png in the same directory as Server.exe. NOTE: tickrate will only be recorded if you are running NS2GmOvermind. The stock server does not have any way to retrieve this information.

CONFIGURATION:
The tool will check the server directory and it's parent directory for hldsupdatetool.exe. If you have it somewhere else, create a ns2update.cfg file in your server directory. Put the full path (include hldsupdatetool.exe) to the update tool on the first line.

This tool can optionally restart your server when it goes from full -> empty (Useful due to the resource leaks in NS2). To enable this, add "--restartwhenempty" to your command line. Note that if you are running the server on something other then the default IP/port, you must set the IP and port using the "-ip X.X.X.X -port 27016" command line arguments in order to make use of this feature.

If you wish to make use of the web interface, you need to enable web administration (see NS2's 'Dedicated Server Usage.txt' for info). NS2Update will create itself a user when it starts up (a new password will be chosen on each restart). Once you have enabled this, you need to add another user (for yourself!). Once you have added the user, you can log into the ns2update webui with your rcon username/password. Guest users will only be able to see the active player list.

The web interface will bind to your 'webadminDomain' IP, with the port being one higher then 'webadminPort'.

BUGS:
If you experience any issues, please <b>open a bug on GitHub</b>. Sending me forum PMs is less then ideal, as the forum PM interface is about 75% broken and not open to the public!

Some screenshots:

This is the public interface, anyone with the URL can view it:
<img src="http://dl.dropbox.com/u/2078961/ns2update/public.png" border="0" class="linked-image" />

Here, you can view your server's console (in real time), as well as execute rcon commands:
<img src="http://dl.dropbox.com/u/2078961/ns2update/console.png" border="0" class="linked-image" />

You can also view all the chat that's happening on the server, though responding is not yet possible (NS2 doesn't currently have a 'say' rcon command):
<img src="http://dl.dropbox.com/u/2078961/ns2update/chat.png" border="0" class="linked-image" />

You can get the binary and source code at <a href="https://github.com/devicenull/NS2Update" target="_blank">https://github.com/devicenull/NS2Update</a> . See the Downloads button in the top right if you want a zip or tar.gz .
«1345

Comments

  • l3lessedl3lessed Join Date: 2010-06-07 Member: 71977Members
    I don't even run or own a server, but this is freaken sweet.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    This is nice, and has been lacking. If only you put this up last week, would have saved me the time. I might still use it as it is probably neater than the auto update method im now using.
  • w0dk4w0dk4 Join Date: 2008-04-22 Member: 64129Members, Constellation, Reinforced - Shadow
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    I've just released an update to fix an issue where server.exe would hang around if ns2update.exe was killed. This update also adds server log archiving.
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    edited May 2011
    Good stuff DN, thank you. Although, when trying to run this in the NS2 server install directory I get this error:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->[NS2Update] DEBUG    Command line args:
    [NS2Update] DEBUG    Checking for server update...
    [NS2Update] DEBUG    Setting update check delay to 300
    [NS2Update] INFO     Server is out of date: current: 0 desired: 18
    [NS2Update] INFO     Starting server update
    Traceback (most recent call last):
      File "ns2update.py", line 108, in <module>
      File "ns2update.py", line 34, in update
      File "subprocess.pyc", line 672, in __init__
      File "subprocess.pyc", line 882, in _execute_child
    WindowsError: [Error 2] The system cannot find the file specified<!--c2--></div><!--ec2-->
    Is this something to do with permissions, environment path, or a problem with python? Any help would be appreciated.

    EDIT: It's worth mentioning the server is up-to-date.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1846309:date=May 14 2011, 06:32 PM:name=McGlaspie)--><div class='quotetop'>QUOTE (McGlaspie @ May 14 2011, 06:32 PM) <a href="index.php?act=findpost&pid=1846309"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Good stuff DN, thank you. Although, when trying to run this in the NS2 server install directory I get this error:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->[NS2Update] DEBUG    Command line args:
    [NS2Update] DEBUG    Checking for server update...
    [NS2Update] DEBUG    Setting update check delay to 300
    [NS2Update] INFO     Server is out of date: current: 0 desired: 18
    [NS2Update] INFO     Starting server update
    Traceback (most recent call last):
      File "ns2update.py", line 108, in <module>
      File "ns2update.py", line 34, in update
      File "subprocess.pyc", line 672, in __init__
      File "subprocess.pyc", line 882, in _execute_child
    WindowsError: [Error 2] The system cannot find the file specified<!--c2--></div><!--ec2-->
    Is this something to do with permissions, environment path, or a problem with python? Any help would be appreciated.

    EDIT: It's worth mentioning the server is up-to-date.<!--QuoteEnd--></div><!--QuoteEEnd-->

    The tool is currently set up so that it assumes hldsupdatetool is one directory below the server.exe. The error you are getting basically means it can't find hldsupdatetool, because it's not where it was expected. I'll add some code to look for hldsupdatetool in the current directory, but for the moment you can simply copy it one directory above your Server.exe file.
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    I would allow the location of the update tool to be either an command line argument or a simple config file. Not everyone is going to have all their files in the same place. Thanks for the info, I'm going to go try that now.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    I just added an update that allows you to optionally specify the path to hldsupdatetool.
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    Awesome. Thank you sir!
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    I've just added the --restartwhenempty flag. This will automatically restart your server after all the players have left it. This is pretty useful for cleaning up after the various resource (memory, CPU) leaks that exist in the server currently. If you want to make use of this I would strongly suggest you set the server's IP and port using the command line arguments (The normal NS2 ones, -ip and -port). The tool will default to using 127.0.0.1:27015 if you don't specify anything.
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Sorry mate just having a bit of trouble getting your auto update working.
    In your readme where it says to make an cfg file and point it to hltools... Uh what command lines do that? :)
    I know how to make the cfg file, but not sure what command it is to point to the correct location of the tools.exe file in program files\valve.\etc...
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1847831:date=May 22 2011, 01:35 AM:name=RockyMarc)--><div class='quotetop'>QUOTE (RockyMarc @ May 22 2011, 01:35 AM) <a href="index.php?act=findpost&pid=1847831"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Sorry mate just having a bit of trouble getting your auto update working.
    In your readme where it says to make an cfg file and point it to hltools... Uh what command lines do that? :)
    I know how to make the cfg file, but not sure what command it is to point to the correct location of the tools.exe file in program files\valve.\etc...<!--QuoteEnd--></div><!--QuoteEEnd-->
    You would put this in the config file:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->C:\Program Files\Valve\HldsUpdateTool.exe<!--c2--></div><!--ec2-->

    Adjust the path as needed of course.
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Okay currently I have the server running just by setting up the server.xml in AppData\Roaming\...
    and running server.exe

    I have copied over dist64 into my current server directory; example -
    C:\NS2Server\dist64

    In C:\NS2Server I have created that .cfg file and will put in that command above (when I get home :P) to point to my hldsupdatetools.exe.

    Do I leave that .cfg file in the main directory or copy it to the dist64 directoy?
    Is the .exe in your dist64 directory automatically try to find this .cfg file?
    (sorry at work at the moment so cannot try it yet)

    Also last night I copied the hldsupdatetools.exe into my server directy and ran your .exe in the dist64 directory, but it started to install all the server files again? I just cancelled it.

    Thank you for your help :)
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    Copy all the files from the dist64 directory to your C:\NS2Server directory. You should end up with Server.exe and NS2Update.exe in the same directory as each other. Once you start the server again, it should detect your existing NS2 install, and tell you it's up to date (or update it as necessary). The config file should go in C:\NS2Server (along with your Server.exe and NS2Update.exe files).
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Ahh there's my problem, I've copied the folder `dist64` into the directory, when I get home I will copy all the files in it, into my ns2 server directory and give it a shot. Cheers.
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Hmm I've done all that, but I still keep getting in the log
    CRITICAL unable to find hldsupdatetool.exe
    after it says that it has found the cfg file
    the path is correct C:\Program Files (x86)\Valve\HLServer\hldsupdatetools.exe
    :(
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1848004:date=May 23 2011, 06:36 AM:name=RockyMarc)--><div class='quotetop'>QUOTE (RockyMarc @ May 23 2011, 06:36 AM) <a href="index.php?act=findpost&pid=1848004"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Hmm I've done all that, but I still keep getting in the log
    CRITICAL unable to find hldsupdatetool.exe
    after it says that it has found the cfg file
    the path is correct C:\Program Files (x86)\Valve\HLServer\hldsupdatetools.exe
    :(<!--QuoteEnd--></div><!--QuoteEEnd-->

    Can you paste me the entire output of the program? You can find it in the ns2update.log file.
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Okay no worries I'll do that when I get home (work blocks the dedicated server login).
    If it helps in the mean time, I remember it saying in the logs, first the time, then saying it has found the ns2update.cfg file, then it says it will now be locating hldsupdatetools.exe
    then on the next line it says CRITICAL unable to find hldsupdatetools.exe, please find the path (or something) or copy it into your server directory.

    I've tried putting the folder path in " " and also renaming hldsupdatetools to exact capital letters.. Hmm but still no luck :(

    Anyway if that's no help, I'll copy it all in when I get home. Cheers.
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Okay log file says (the last few lines)
    05-23 18:45 root DEBUG Command line args:
    05-23 18:45 root DEBUG Found ns2update.cfg file, loading hldsupdatetool path
    05-23 18:45 root CRITICAL Unable to find hldsupdatetool.exe, please copy to server directory or see README

    in my config file -
    C:\Program Files (x86)\Valve\HLServer\HldsUpdateTool.exe
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    Does your automatic updates only works with Windows ?

    I'm trying to use it with wine but I've some errors.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    <!--quoteo(post=1848150:date=May 24 2011, 08:07 AM:name=RockyMarc)--><div class='quotetop'>QUOTE (RockyMarc @ May 24 2011, 08:07 AM) <a href="index.php?act=findpost&pid=1848150"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Okay log file says (the last few lines)
    05-23 18:45 root DEBUG Command line args:
    05-23 18:45 root DEBUG Found ns2update.cfg file, loading hldsupdatetool path
    05-23 18:45 root CRITICAL Unable to find hldsupdatetool.exe, please copy to server directory or see README

    in my config file -
    C:\Program Files (x86)\Valve\HLServer\HldsUpdateTool.exe<!--QuoteEnd--></div><!--QuoteEEnd-->
    I've just released an update to fix this. The configuration file was actually being ignored.

    <!--quoteo(post=1848174:date=May 24 2011, 10:37 AM:name=vlnc)--><div class='quotetop'>QUOTE (vlnc @ May 24 2011, 10:37 AM) <a href="index.php?act=findpost&pid=1848174"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Does your automatic updates only works with Windows ?

    I'm trying to use it with wine but I've some errors.<!--QuoteEnd--></div><!--QuoteEEnd-->
    I have not tested it in wine, nor do I have any plans to. As it's written in python, you can run it natively with very minimal changes. I'm not going to be releasing a version that works in linux until the server has a native port. If you want to try it yourself, I believe these to be the only two lines you would need to change:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->paths = [ "../hldsupdatetool.exe", "hldsupdatetool.exe" ]<!--c2--></div><!--ec2-->
    and
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->self.serverProc = subprocess.Popen("Server.exe %s" % self.serverArgs, stdin=None, stdout=subprocess.PIPE)<!--c2--></div><!--ec2-->
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Members, Reinforced - Shadow
    Downloaded the new version, worked a charm!
    Cheers :)
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    <!--quoteo(post=1848300:date=May 25 2011, 03:26 AM:name=devicenull)--><div class='quotetop'>QUOTE (devicenull @ May 25 2011, 03:26 AM) <a href="index.php?act=findpost&pid=1848300"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I have not tested it in wine, nor do I have any plans to. As it's written in python, you can run it natively with very minimal changes. I'm not going to be releasing a version that works in linux until the server has a native port. If you want to try it yourself, I believe these to be the only two lines you would need to change:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->paths = [ "../hldsupdatetool.exe", "hldsupdatetool.exe" ]<!--c2--></div><!--ec2-->
    and
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->self.serverProc = subprocess.Popen("Server.exe %s" % self.serverArgs, stdin=None, stdout=subprocess.PIPE)<!--c2--></div><!--ec2--><!--QuoteEnd--></div><!--QuoteEEnd-->

    Ok thanks, I'll try to change that.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    I've been running this on my server since the release, I'd suggest everyone make use of the --restartwhenempty flag. It's quite effective in dealing with NS2's various resource leaks (memory leaks, high CPU even when empty, etc).
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    I've this error in Schedule event :

    The activation context creation failed pour « C:\ns2server\ns2update.exe ». Assembly dépendant Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" introuvable. Utilisez sxstrace.exe pour un diagnostic détaillé.

    do I need to install visual basic ? what version (9?).
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    edited June 2011
    You don't need visual basic, but you do need the Visual Studio 2008 runtimes, either <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=a5c84275-3b97-4ab7-a40d-3802b2af5fc2&displaylang=en" target="_blank">32bit</a> or <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=BA9257CA-337F-4B40-8C14-157CFDFFEE4E" target="_blank">64bit</a>
  • wulf 21wulf 21 Join Date: 2011-05-03 Member: 96875Members
    You screwed up the bb syntax, theres an "url=" missing XD.
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    edited June 2011
    <!--quoteo(post=1849392:date=Jun 1 2011, 12:07 AM:name=devicenull)--><div class='quotetop'>QUOTE (devicenull @ Jun 1 2011, 12:07 AM) <a href="index.php?act=findpost&pid=1849392"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->You don't need visual basic, but you do need the Visual Studio 2008 runtimes, either <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=a5c84275-3b97-4ab7-a40d-3802b2af5fc2&displaylang=en" target="_blank">32bit</a> or [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=BA9257CA-337F-4B40-8C14-157CFDFFEE4E]64bit[/url]<!--QuoteEnd--></div><!--QuoteEEnd-->

    Thank you devicenull

    Ok it's works now, just have an errors when i launch my script.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->06-01 11:50 root         DEBUG    Logging to 2011.06.01.1150.log
    06-01 11:50 root         CRITICAL Server has died, restarting!
    06-01 11:50 root         INFO     Server started, pid 948
    06-01 11:50 root         DEBUG    Logging to 2011.06.01.1150.log
    06-01 11:50 root         CRITICAL Server has died, restarting!
    06-01 11:50 root         INFO     Server started, pid 2052
    06-01 11:50 root         DEBUG    Logging to 2011.06.01.1150.log
    06-01 11:50 root         CRITICAL Server has died, restarting!<!--c2--></div><!--ec2-->

    my script restart :
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->@echo OFF

    echo "Kill ns2update.exe"

    taskkill /F /IM ns2update.exe

    echo "Lancement Serveur"

    cd C:\ns2server

    ns2update.exe --restartwhenempty -ip 88.190.18.171 -p 27016

    REM server.exe -file C:\ns2server\server.xml -game C:\ns2server\NS2GmOvrmind<!--c2--></div><!--ec2-->

    here is the log from ns2update.log
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->06-01 11:54 root         DEBUG    Command line args: --restartwhenempty -ip 88.190.18.171 -p 27016
    06-01 11:54 root         DEBUG    Found ns2update.cfg file, loading hldsupdatetool path
    06-01 11:54 root         DEBUG    Added path from config file: C:\Program Files (x86)\Valve\HLServer\hldsupdatetool.exe
    06-01 11:54 root         INFO     Detected server IP as 88.190.18.171:27017
    06-01 11:54 root         INFO     Server will be automatically restarted when empty
    06-01 11:54 root         DEBUG    Checking for server update...
    06-01 11:54 root         INFO     Server is out of date: current: 0 desired: 18
    06-01 11:54 root         INFO     Performing inital server update
    06-01 11:54 root         INFO     Starting server update
    06-01 11:54 root         INFO     Server update complete!
    06-01 11:54 root         INFO     Server started, pid 1244
    06-01 11:54 root         DEBUG    Logging to 2011.06.01.1154.log
    06-01 11:54 root         CRITICAL Server has died, restarting!
    06-01 11:54 root         INFO     Server started, pid 2856
    06-01 11:54 root         DEBUG    Logging to 2011.06.01.1154.log<!--c2--></div><!--ec2-->
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    What do the log files say? Take a look at serverlogs/2011.06.01.1154.log
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    <!--quoteo(post=1849447:date=Jun 1 2011, 02:26 PM:name=devicenull)--><div class='quotetop'>QUOTE (devicenull @ Jun 1 2011, 02:26 PM) <a href="index.php?act=findpost&pid=1849447"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->What do the log files say? Take a look at serverlogs/2011.06.01.1154.log<!--QuoteEnd--></div><!--QuoteEEnd-->

    here is the content of this log :

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Invalid command line settings.
    Invalid command line settings.<!--c2--></div><!--ec2-->
Sign In or Register to comment.