Jump to content

restart all services on specific box.


dexion

Recommended Posts

I saw the restart all servers scripts and they are great except i have servers spread across 3 timezones and would like to restart them at 7am at the specific timezone they are in.

 

Can anyone show me how to modify the restart scrips to either:

 

restart all services on box x (hopefully i can add in say the x boxes in california and make it 1 script, the x in nyc etc) then I only need to have 3 versions one for each timezone.

OR even better,

Restart all services in a specific datacenter location.

 

Thanks

dex

Link to comment
Share on other sites

Use this script:

http://clientforums.tcadmin.com/showthread.php?t=201

 

Change this:

Dim services() As Service = Service.GetServices()

To this:

Dim services() As Service = Service.GetServicesByServerId(TCAdminSDK.Info.GetThisServerId)

 

Run the script on each server as a scheduled task at the time you want. It will only restart the services on that server.

Link to comment
Share on other sites

  • 3 weeks later...

Ok i did that, ended up with:

 

<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.GetServicesByServerId(TCAdminSDK.Info.GetThisServerId)
     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>

Link to comment
Share on other sites

while that does look like i can restart the servers on the box on demand

it doesnt appear that i can do it on a schedule. So, the script i was working on still seems like my best bet. Can anyone suggest a way to make it work *fixing the compile errors?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use