Auto updates

endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
Since the recent influx of updates the past week, I thought others might be able to use what I use to keep my servers up to date. I doubt you will be able to get this to work for you unless you can read batch files. But I'll try explain.

Each server.exe runs under its own user account, those user accounts are:
ns2s = server #1
ns2f = server #2
ns2c = server #3
ns2g = server #4 (private)
Administrator group isn't required, can just be standard users.

Each of these servers is based in c:\ns2game\%username%, so c:\ns2game\ns2s for the first server. There is a 5th location, called c:\ns2game\ns2b, this server instance isn't played, but is used for updating every 1700 seconds (configurable).

When the ns2b instance updates, it will hash certain important game files out to a file, and then compare those hashes, to the hashes of the existing game servers. If it notices a difference in any of these files, it will send a kill command to that server instance (based on its username). Whenever a server.exe instance is killed, it will always try and update.


I've had this system running since they removed the ability to update using hldsupdatetool, and it's worked for every single patch, and I believe it will continue to work.

<a href="https://dl.dropbox.com/u/17532519/ns2game.7z" target="_blank">https://dl.dropbox.com/u/17532519/ns2game.7z</a>

Comments

  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    <!--quoteo(post=2032027:date=Nov 22 2012, 04:38 AM:name=endar)--><div class='quotetop'>QUOTE (endar @ Nov 22 2012, 04:38 AM) <a href="index.php?act=findpost&pid=2032027"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Since the recent influx of updates the past week, I thought others might be able to use what I use to keep my servers up to date. I doubt you will be able to get this to work for you unless you can read batch files. But I'll try explain.

    Each server.exe runs under its own user account, those user accounts are:
    ns2s = server #1
    ns2f = server #2
    ns2c = server #3
    ns2g = server #4 (private)
    Administrator group isn't required, can just be standard users.

    Each of these servers is based in c:\ns2game\%username%, so c:\ns2game\ns2s for the first server. There is a 5th location, called c:\ns2game\ns2b, this server instance isn't played, but is used for updating every 1700 seconds (configurable).

    When the ns2b instance updates, it will hash certain important game files out to a file, and then compare those hashes, to the hashes of the existing game servers. If it notices a difference in any of these files, it will send a kill command to that server instance (based on its username). Whenever a server.exe instance is killed, it will always try and update.


    I've had this system running since they removed the ability to update using hldsupdatetool, and it's worked for every single patch, and I believe it will continue to work.

    <a href="https://dl.dropbox.com/u/17532519/ns2game.7z" target="_blank">https://dl.dropbox.com/u/17532519/ns2game.7z</a><!--QuoteEnd--></div><!--QuoteEEnd-->

    Now if only empty servers used less than 1.2GB of ram, memory leak much...
  • CoTTonCoTTon Join Date: 2005-02-28 Member: 42773Members
    As I told you on Steam Ender - you are a fking god.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    <!--quoteo(post=2032032:date=Nov 22 2012, 08:43 PM:name=ZEROibis)--><div class='quotetop'>QUOTE (ZEROibis @ Nov 22 2012, 08:43 PM) <a href="index.php?act=findpost&pid=2032032"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Now if only empty servers used less than 1.2GB of ram, memory leak much...<!--QuoteEnd--></div><!--QuoteEEnd-->
    I'm always running four servers at a time, I have 8GB installed, these days I don't really have much issue keeping in that limit. The above method I posted doesnt ever run an extra instance of the server process, the only additional memory usage you would incur are from the ping.exe processes and the constant steamcmd processes. I'm not sure what your comment means?
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    edited November 2012
    <!--quoteo(post=2032035:date=Nov 22 2012, 04:48 AM:name=endar)--><div class='quotetop'>QUOTE (endar @ Nov 22 2012, 04:48 AM) <a href="index.php?act=findpost&pid=2032035"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I'm always running four servers at a time, I have 8GB installed, these days I don't really have much issue keeping in that limit. The above method I posted doesnt ever run an extra instance of the server process, the only additional memory usage you would incur are from the ping.exe processes and the constant steamcmd processes. I'm not sure what your comment means?<!--QuoteEnd--></div><!--QuoteEEnd-->

    Ah I see it just keep trying to update a blank directory of files. Ok that makes a lot more sense I understand now what is going on.

    Also wanted to recommend a feature:

    Is there any way it could query the live servers and only shut down for update if player count is <X? Or when the game ends, would also be great if there was some warning to the players the server is going to restart.

    Obviously the value of updating like this is to minimize impact to players but in order to do that fully the players need to be made aware of what is going on and have any inconveniences as minimized as possible.

    On another note as for memory I am going to run some test here and make a thread about this b/c something is wrong. I managed to get an empty server to drop to only 20mb of ram usage after a map change but a fresh start it uses like 900mb the 20mb crept up to 70mb but why would it not drop to that on its own, strange.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    You can do it if playercount is below X, thats quite easy, you can just use qstat to get a player list, and then kill if it meets your requirements. Unforutnately to find out if a round has ended is a bit harder, I don't know of a way to do it.

    I guess it comes down to your priorities. For me, updates are normally released around 1-4PM, and I don't get home until about 5-6, so thats potentially 5 hours where the servers are unplayable.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    <!--quoteo(post=2032047:date=Nov 22 2012, 04:57 AM:name=endar)--><div class='quotetop'>QUOTE (endar @ Nov 22 2012, 04:57 AM) <a href="index.php?act=findpost&pid=2032047"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->You can do it if playercount is below X, thats quite easy, you can just use qstat to get a player list, and then kill if it meets your requirements. Unforutnately to find out if a round has ended is a bit harder, I don't know of a way to do it.

    I guess it comes down to your priorities. For me, updates are normally released around 1-4PM, and I don't get home until about 5-6, so thats potentially 5 hours where the servers are unplayable.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Actually I just thought of another way, is it possible for you to make this batch script not preform an update at all but instead send an e-mail!?

    With the correct software it is possible from a cellphone to communicate with the players, see if the map has ended and update the server in a very short time.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Instead of running the update command, replace it with something like:
    sendemail.exe -f servername@something.com-t youremail@gmail.com -u Sever update available. -m Server update now available. -s yoursmtphost.com

    Download the program from here:
    <a href="http://caspian.dotconf.net/menu/Software/SendEmail/" target="_blank">http://caspian.dotconf.net/menu/Software/SendEmail/</a>

    You would need an smtp server which is able to send email, sometimes your ISP provides one.
  • VolcanoVolcano Join Date: 2011-07-27 Member: 112496Members, Constellation
    Good guy Endar helping the servers admins :)
  • MaxMax Technical Director, Unknown Worlds Entertainment Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
    Nice job endar. We've been thinking about integrating something into the server that will aid this, but we aren't sure exactly what that would be. One thing we are considering is making is so that the server can (optionally) check if there is a new build out when a game ends, and if there is it shuts down the process. Clients would also get a notification when a new build is released.

    We are looking for feedback and suggestions on how such a system might work, so let us know what you think.
  • ZekZek Join Date: 2002-11-10 Member: 7962Members, NS1 Playtester, Constellation, Reinforced - Shadow
    Yeah I think the server should just have an option(defaulting to true) to automatically restart on map change when an update is available. All it needs is a quick warning immediately beforehand, or a good disconnect message.
  • 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
    It would need to be much more extensive then that Zek. You've got the possibility of the executable being updated.

    Max, could you use your auto-update code you released several years ago?
    <a href="http://www.unknownworlds.com/developer/updater/" target="_blank">http://www.unknownworlds.com/developer/updater/</a>

    Take it as a wrapper program that the Server.exe would launch to perform whatever SteamCmd functions you need. Then run the server again. The trick would be to allow for the full cmd-line call to the server.exe to be configurable. This would let server admins do whatever they need to (Affinity, map, mod storage, etc). Server admins are already needing to install SteamCmd for updates, so you could just give us a new "auto-update config" type settings file.

    Personally, I would also provide a stub or JSON hook to push an Admin type message (the WebUI already does this), so player's can be warned the server is going to restart.

    In fact, if admins had the option to dictate a scheduled restart (with/without updates performed), or even when certain conditions are met...that would be awesome.


    Thanks for posting this Endar! I'm going to use it for 156 servers. :D
  • GuspazGuspaz Join Date: 2002-11-01 Member: 2862Members, Constellation
    edited November 2012
    <!--quoteo(post=2032327:date=Nov 22 2012, 02:10 PM:name=McGlaspie)--><div class='quotetop'>QUOTE (McGlaspie @ Nov 22 2012, 02:10 PM) <a href="index.php?act=findpost&pid=2032327"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->It would need to be much more extensive then that Zek. You've got the possibility of the executable being updated.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I think you're misunderstanding him. He's not saying that the server should update on map change to avoid disconnecting clients (which would happen anyhow since clients need to be restarted to get the update), but that the server should delay updates until mapchange so that the current game is allowed to finish.

    The downside of Endar's approach is that everybody playing on the server when an update is triggered gets booted, aborting the game in progress. Zek's proposal is to delay the update until the current map ends. Everybody gets disconnected, but they get to finish their game.

    This is probably still possible with Endar's approach. When the command and control process decides it has to update the four servers, it begins polling them at a high rate (the webserver API is handled from a different thread, so this wouldn't impact performance). As soon as it notices the map change on one of them, it kills that instance so that it can be updated. It then stops polling that server. When all instances have been restarted in this manner, you're done, and nobody had their game interrupted.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    <!--quoteo(post=2032370:date=Nov 23 2012, 06:05 AM:name=Guspaz)--><div class='quotetop'>QUOTE (Guspaz @ Nov 23 2012, 06:05 AM) <a href="index.php?act=findpost&pid=2032370"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->This is probably still possible with Endar's approach. When the command and control process decides it has to update the four servers, it begins polling them at a high rate (the webserver API is handled from a different thread, so this wouldn't impact performance). As soon as it notices the map change on one of them, it kills that instance so that it can be updated. It then stops polling that server. When all instances have been restarted in this manner, you're done, and nobody had their game interrupted.<!--QuoteEnd--></div><!--QuoteEEnd-->
    I like that idea, although I don't use the webconsole. I guess its possible to do with qstat.

    And the best solution supported by UWE? I think checking at the end of every round (not map, since some servers are 24/7), and then sending an update message, then kill would be best.
  • GuspazGuspaz Join Date: 2002-11-01 Member: 2862Members, Constellation
    Doesn't really matter how you do it; the web API is just a convenient way to poll the server with minimal effort (heck, just run wget to pull the server info and parse the map name), but anything polling A2S works too, whatever the easiest way to get the current map from the server.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    <!--quoteo(post=2032197:date=Nov 22 2012, 10:01 AM:name=Max)--><div class='quotetop'>QUOTE (Max @ Nov 22 2012, 10:01 AM) <a href="index.php?act=findpost&pid=2032197"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Nice job endar. We've been thinking about integrating something into the server that will aid this, but we aren't sure exactly what that would be. One thing we are considering is making is so that the server can (optionally) check if there is a new build out when a game ends, and if there is it shuts down the process. Clients would also get a notification when a new build is released.

    We are looking for feedback and suggestions on how such a system might work, so let us know what you think.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Ideally the server should have two options: auto update or notify admin (notify admin sends email)

    The email send/non auto update is important for moded servers that may break with the update as to prevent crash looping or who knows what could occur.

    Now as for the auto update part it should work simply as follows:

    1. After game ends server immediately checks for updates

    2. If update is found users are given a CONFIGURABLE MESSAGE (This allows server admins to say for example: "A game update has been released and the server will now restart. Please restart your game to get the update. To rejoin this server after the update enter: connect ns2.ibisgaming.com into your game console." as you see most of that message is generic and informs users but we also want to tell them how to get back to the server so they can all continue playing together after the update.

    3. Server after warning users a few times then restarts for the update.

    4. Method of auto updating should work with keep alive scripts for example many of us have scripts that will relaunch the server process if it ends so the auto update method needs to take this into account.

    5. When the auto update method is used the server searches for updates and updates itself every time the server process is started (this makes it so that it works with keep alive scripts and game hosting panels)
  • GuspazGuspaz Join Date: 2002-11-01 Member: 2862Members, Constellation
    Don't really need all the messaging and warning stuff, we just need disconnect message support. Kills a bunch of birds with one stone; allows explanations of why users were kicked from a server, either a message from an admin, or perhaps from the server saying it's updating.
  • Taylor89Taylor89 Join Date: 2012-11-23 Member: 172980Members
    I've been looking for a mailing list to join that announces when server updates are available and the changelog if possible.
    I've searched around but haven't found one.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    edited November 2012
    <!--quoteo(post=2032966:date=Nov 23 2012, 12:02 PM:name=Guspaz)--><div class='quotetop'>QUOTE (Guspaz @ Nov 23 2012, 12:02 PM) <a href="index.php?act=findpost&pid=2032966"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Don't really need all the messaging and warning stuff, we just need disconnect message support. Kills a bunch of birds with one stone; allows explanations of why users were kicked from a server, either a message from an admin, or perhaps from the server saying it's updating.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Exactly the ability to send parameters to define the message text given on disconnect would be GREAT!!

    <!--quoteo(post=2033042:date=Nov 23 2012, 01:58 PM:name=Taylor89)--><div class='quotetop'>QUOTE (Taylor89 @ Nov 23 2012, 01:58 PM) <a href="index.php?act=findpost&pid=2033042"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I've been looking for a mailing list to join that announces when server updates are available and the changelog if possible.
    I've searched around but haven't found one.<!--QuoteEnd--></div><!--QuoteEEnd-->

    There is not one but you can post in this thread about how you want one: <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=125007" target="_blank">http://www.unknownworlds.com/ns2/forums/in...howtopic=125007</a>
Sign In or Register to comment.