Auto updates
endar
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>
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
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...
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?
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.
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.
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.
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.
We are looking for feedback and suggestions on how such a system might work, so let us know what you think.
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
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.
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.
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)
I've searched around but haven't found one.
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>