Automatic Updates

devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
edited February 2012 in Modding
For your server
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: http://www.zhacks.com/2010/04/10/disable-a...-be-read-popup/ . 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 open a bug on GitHub. 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:
image

Here, you can view your server's console (in real time), as well as execute rcon commands:
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):
image

You can get the binary and source code at https://github.com/devicenull/NS2Update . See the Downloads button in the top right if you want a zip or tar.gz .
Post edited by Unknown User on
Rent NS2 Dedicated Servers at www.gameservers.com
«1345

Comments

  • l3lessedl3lessed Join Date: 2010-06-07 Member: 71977Posts: 374Members
    I don't even run or own a server, but this is freaken sweet.
  • endarendar Join Date: 2010-07-27 Member: 73256Posts: 620Members, 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: 64129Posts: 351Members, Constellation, Reinforced - Shadow
    Cool, thx!
    ArmoryChamber.net [ConstellationSlots/AdvancedBalance]
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, 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.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • McGlaspieMcGlaspie www.team156.com Lord MuckyMuck of the Programmers Join Date: 2010-07-26 Member: 73044Posts: 824Members, NS2 Playtester, Squad Five Blue, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester, Community Dev Team
    edited May 2011
    Good stuff DN, thank you. Although, when trying to run this in the NS2 server install directory I get this error:
    CODE
    [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

    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.
    Post edited by Unknown User on

    Colored Skins Mod ( Forum Thread - Steam Workshop )
    Marine vs Marine Mod ( Forum Thread - Steam Workshop - Mod Tracker )
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    QUOTE (McGlaspie @ May 14 2011, 06:32 PM) »
    Good stuff DN, thank you. Although, when trying to run this in the NS2 server install directory I get this error:
    CODE
    [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

    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.


    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.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • McGlaspieMcGlaspie www.team156.com Lord MuckyMuck of the Programmers Join Date: 2010-07-26 Member: 73044Posts: 824Members, NS2 Playtester, Squad Five Blue, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester, Community Dev Team
    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.

    Colored Skins Mod ( Forum Thread - Steam Workshop )
    Marine vs Marine Mod ( Forum Thread - Steam Workshop - Mod Tracker )
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    I just added an update that allows you to optionally specify the path to hldsupdatetool.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • McGlaspieMcGlaspie www.team156.com Lord MuckyMuck of the Programmers Join Date: 2010-07-26 Member: 73044Posts: 824Members, NS2 Playtester, Squad Five Blue, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester, Community Dev Team
    Awesome. Thank you sir!

    Colored Skins Mod ( Forum Thread - Steam Workshop )
    Marine vs Marine Mod ( Forum Thread - Steam Workshop - Mod Tracker )
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, 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.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Posts: 472Members, 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: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    QUOTE (RockyMarc @ May 22 2011, 01:35 AM) »
    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...

    You would put this in the config file:
    CODE
    C:\Program Files\Valve\HldsUpdateTool.exe


    Adjust the path as needed of course.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Posts: 472Members, 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: 15967Posts: 1,538Members, 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).
    Rent NS2 Dedicated Servers at www.gameservers.com
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Posts: 472Members, 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: 69519Posts: 472Members, 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: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    QUOTE (RockyMarc @ May 23 2011, 06:36 AM) »
    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
    :(


    Can you paste me the entire output of the program? You can find it in the ns2update.log file.
    Rent NS2 Dedicated Servers at www.gameservers.com
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Posts: 472Members, 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: 69519Posts: 472Members, 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: 73921Posts: 241Members, 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: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    QUOTE (RockyMarc @ May 24 2011, 08:07 AM) »
    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

    I've just released an update to fix this. The configuration file was actually being ignored.

    QUOTE (vlnc @ May 24 2011, 10:37 AM) »
    Does your automatic updates only works with Windows ?

    I'm trying to use it with wine but I've some errors.

    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:

    CODE
    paths = [ "../hldsupdatetool.exe", "hldsupdatetool.exe" ]

    and
    CODE
    self.serverProc = subprocess.Popen("Server.exe %s" % self.serverArgs, stdin=None, stdout=subprocess.PIPE)

    Rent NS2 Dedicated Servers at www.gameservers.com
  • RockyMarcRockyMarc Join Date: 2009-11-24 Member: 69519Posts: 472Members, Reinforced - Shadow
    Downloaded the new version, worked a charm!
    Cheers :)
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Posts: 241Members, Squad Five Blue
    QUOTE (devicenull @ May 25 2011, 03:26 AM) »
    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:

    CODE
    paths = [ "../hldsupdatetool.exe", "hldsupdatetool.exe" ]

    and
    CODE
    self.serverProc = subprocess.Popen("Server.exe %s" % self.serverArgs, stdin=None, stdout=subprocess.PIPE)


    Ok thanks, I'll try to change that.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, 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).
    Rent NS2 Dedicated Servers at www.gameservers.com
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Posts: 241Members, 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: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    edited June 2011
    You don't need visual basic, but you do need the Visual Studio 2008 runtimes, either 32bit or 64bit
    Post edited by Unknown User on
    Rent NS2 Dedicated Servers at www.gameservers.com
  • wulf 21wulf 21 Join Date: 2011-05-03 Member: 96875Posts: 163Members
    You screwed up the bb syntax, theres an "url=" missing XD.
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Posts: 241Members, Squad Five Blue
    edited June 2011
    QUOTE (devicenull @ Jun 1 2011, 12:07 AM) »
    You don't need visual basic, but you do need the Visual Studio 2008 runtimes, either 32bit or [http://www.microsoft.com/downloads/en/details.aspx?FamilyID=BA9257CA-337F-4B40-8C14-157CFDFFEE4E]64bit[/url]


    Thank you devicenull

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

    CODE
    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!


    my script restart :
    CODE
    @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


    here is the log from ns2update.log
    CODE
    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
    Post edited by Unknown User on
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Posts: 1,538Members, NS2 Playtester, Squad Five Blue
    What do the log files say? Take a look at serverlogs/2011.06.01.1154.log
    Rent NS2 Dedicated Servers at www.gameservers.com
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Posts: 241Members, Squad Five Blue
    QUOTE (devicenull @ Jun 1 2011, 02:26 PM) »
    What do the log files say? Take a look at serverlogs/2011.06.01.1154.log


    here is the content of this log :

    CODE
    Invalid command line settings.
    Invalid command line settings.
«1345
Sign In or Register to comment.