LFA Posted June 25, 2005 Share Posted June 25, 2005 Remember to set waitForUserAction to false if you run this as a scheduled task These scripts should be run on the master server since they restart all the game servers on every machine. Restart all game servers: <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Imports TCAdminSDK.Objects Public Class RestartGameServers Public Shared Sub Main() 'Get a list of all services Dim services() As Service = Service.GetServices() for each s as Service in services If s.CurrentStatus = ServiceStatus.Running Then Console.WriteLine("Restarting " & s.ServiceID) s.Stop() Threading.Thread.CurrentThread.Sleep(1000) s.Start() 'Wait a few seconds before restarting the 'next service to avoid high loads on server Threading.Thread.CurrentThread.Sleep(10000) End If next Console.WriteLine("Done. Press any key to continue.") End Sub End Class ]]></scriptCode> </tcascript> Restart all game servers that have a specific game id. Just replace TCXXXXXXXXX with the game id you want to restart <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Imports TCAdminSDK.Objects Public Class RestartGameServers Public Shared Sub Main() 'Set the game id to restart dim GameID as string = "TCXXXXXXXXX" 'Get a list of all services Dim services() As Service = Service.GetServices() for each s as Service in services If s.CurrentStatus = ServiceStatus.Running and s.GameId.Equals(GameID) Then Console.WriteLine("Restarting " & s.ServiceID) s.Stop() Threading.Thread.CurrentThread.Sleep(1000) s.Start() 'Wait a few seconds before restarting the 'next service to avoid high loads on server Threading.Thread.CurrentThread.Sleep(10000) End If next Console.WriteLine("Done. Press any key to continue.") End Sub End Class ]]></scriptCode> </tcascript> Link to comment Share on other sites More sharing options...
LFA Posted July 6, 2005 Author Share Posted July 6, 2005 Stop only. <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Imports TCAdminSDK.Objects Public Class RestartGameServers Public Shared Sub Main() 'Get a list of all services Dim services() As Service = Service.GetServices() for each s as Service in services If s.CurrentStatus = ServiceStatus.Running Then s.Stop() End If next Console.WriteLine("Done. Press any key to continue.") End Sub End Class ]]></scriptCode> </tcascript> Start only. <tcascript> <language name="VB" /> <waitForUserAction value="true"/> <scriptCode><![CDATA[ Imports System Imports TCAdminSDK.Objects Public Class RestartGameServers Public Shared Sub Main() 'Get a list of all services Dim services() As Service = Service.GetServices() for each s as Service in services If s.StartupType <> TCAdminSDK.Objects.ServiceStartup.Disabled Then s.Start() 'next service to avoid high loads on server Threading.Thread.CurrentThread.Sleep(10000) End If next Console.WriteLine("Done. Press any key to continue.") End Sub End Class ]]></scriptCode> </tcascript> Link to comment Share on other sites More sharing options...
tangogc Posted July 14, 2005 Share Posted July 14, 2005 Link to comment Share on other sites More sharing options...
24play Posted February 6, 2006 Share Posted February 6, 2006 Another great idea.. Does anyone recommend any other games they think should be restarted on a regular basis? Apart from Source servers? Thanks Link to comment Share on other sites More sharing options...
ECF Posted February 6, 2006 Share Posted February 6, 2006 Medal of Honor servers seem to have problems with losing rcon abilites after so long. However, the whole box needs to be restarted not just the game instance. Link to comment Share on other sites More sharing options...
24play1 Posted February 6, 2006 Share Posted February 6, 2006 ooooof thats a handy bit of info ty ECF Link to comment Share on other sites More sharing options...
24play Posted February 21, 2006 Share Posted February 21, 2006 Howdy I am using the restart script but want to add more game id's Public Shared Sub Main() 'Set the game id to restart dim GameID as string = "TCXXXXXXXXX" Do i just Public Shared Sub Main() 'Set the game id to restart dim GameID as string = "TCXXXXXXXXX; TCXXXXXXXXX; TCXXXXXXXXX" or do I have to do a seperate script for each one? Link to comment Share on other sites More sharing options...
ECF Posted February 21, 2006 Share Posted February 21, 2006 Setup a seperate script for each one would probably be the best way to do it. That way you can specify different times in the scheduled task as to avoid lagging your servers with a ton of games all resatrting at the same time. Link to comment Share on other sites More sharing options...
24play Posted February 21, 2006 Share Posted February 21, 2006 ah great thinking, will do that as it'll only take a couple of mins. Cheers Link to comment Share on other sites More sharing options...
DanCF Posted August 3, 2006 Share Posted August 3, 2006 I see all servers, and all servers on a specific game, but what could I do to just restart 1 specific server which keeps doing wierd things after being up for a long time. Also where do I run this script from? Link to comment Share on other sites More sharing options...
LFA Posted August 5, 2006 Author Share Posted August 5, 2006 Use the script and change this line: Dim services() As Service = Service.GetServices() To: Dim services() As Service = Service.GetServicesByUserId("YourClientUserId") Replace YourClientUserId with your client's id. Link to comment Share on other sites More sharing options...
franky500 Posted November 15, 2006 Share Posted November 15, 2006 i cant seem to get this to run. I know im doing it wrong just dont know what. (first time looking at the scripts for TCAdmin and have no idea!!) I am looking to get the script to start just the one server. and just have a schedueled task to run it / them. Trouble is i have copied / pasted the code from the first post and changed the TCService ID, but it then just opens a console box and sais: An exception occured while compiling the script Object reference not set to an instance of an object. IS there a specific place i need to run this from? any pointers? Thanks Link to comment Share on other sites More sharing options...
LFA Posted November 16, 2006 Author Share Posted November 16, 2006 Try copying the scripts again. The script tags broke when we changed the forum software. Link to comment Share on other sites More sharing options...
franky500 Posted November 16, 2006 Share Posted November 16, 2006 Thanks it will now run it. but it doesnt restart the server for some reason, anything else i need at all? Link to comment Share on other sites More sharing options...
LFA Posted November 17, 2006 Author Share Posted November 17, 2006 If you use the second script you need to change TCXXXXXXXXX to the game id you want to restart. The others should work without any changes. The scripts don't restart the server. It restarts the game servers. Link to comment Share on other sites More sharing options...
franky500 Posted November 17, 2006 Share Posted November 17, 2006 ye s i know. thats already been edited to the TC game ID, i know it restarts game servers. thats what i want. i was physically sitting in the server at the time and it did not restart. Although i have tried both, the TCAdmin service ID that needs to be in there. should it be the longer or shorter one (shorter one being the one in the blocked out box when editing a server. Longer appearing just above that) and im assuming the script can be run from anywhere on the master server? Thanks Link to comment Share on other sites More sharing options...
LFA Posted November 17, 2006 Author Share Posted November 17, 2006 It is not the service id. You need to set the game id. The one from System Settings > Supported Games. The scripts can be executed from any location on the master. Link to comment Share on other sites More sharing options...
ECF Posted November 17, 2006 Share Posted November 17, 2006 I think you are attempting to restart an individual game server? If so, this script is not designed to do that. It is designed to restart all game servers of a certain type. eg. Counterstrike Link to comment Share on other sites More sharing options...
franky500 Posted November 17, 2006 Share Posted November 17, 2006 Ahh right, in that case , My mistake. Is there a script around that can do that? although thinking about it if i have TCAdmin set for automatic for that server and just create a schedule to Stop the service. somehow. Thanks. Link to comment Share on other sites More sharing options...
ECF Posted November 17, 2006 Share Posted November 17, 2006 Find the service name for that server in the services list and create two batch files. One for start and one for stop. Start one would look like this net start <servicename> Stop one will look like this net stop <servicename> Then you can set 2 windows scheduled tasks. 1 for start and 1 for stop at whatever times you would like. Link to comment Share on other sites More sharing options...
franky500 Posted November 18, 2006 Share Posted November 18, 2006 Works like a charm. Thanks ECF Link to comment Share on other sites More sharing options...
michael18 Posted November 19, 2006 Share Posted November 19, 2006 do you guys know a quicker method to get the status of all services? im using this code but its very sluggish with ~100 servers Dim services() As Service = Service.GetServices() for each s as Service in services If s.ServiceID.Equals( id ) Then return s.CurrentStatus end if next Link to comment Share on other sites More sharing options...
LFA Posted November 19, 2006 Author Share Posted November 19, 2006 From the code I see you are looping through all the game servers just to get the status of one. Just do this: Dim s as new TCAdminSDK.Objects.Service s.ServiceID = id s.Find() return s.CurrentStatus Link to comment Share on other sites More sharing options...
michael18 Posted November 20, 2006 Share Posted November 20, 2006 yeah tried that as well but it still takes over 1 min for ~100 servers which is no good to me also tried this which aint any quicker Dim services() As Service = Service.GetServices() for each s as Service in services response.write(s.CurrentStatus) next Link to comment Share on other sites More sharing options...
matrix4583 Posted May 8, 2007 Share Posted May 8, 2007 where do i put in the script? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.