Reboot Enterprise Server

1052
3
Jump to solution
01-09-2018 08:41 AM
LarryAdgate
Occasional Contributor

For better maintenance to our Web Map Services, is there a Python Script out there to Reboot our Enterprise Server? 

Thanks,

Larry Adgate`         

0 Kudos
1 Solution

Accepted Solutions
LarryAdgate
Occasional Contributor

Hi Jonathan, typically Monday morning I arrive at the office to inspect all my Web Services and they are all offline. As a remedy, I submit a request to IT to reboot the Enterprise Server and that seems to resolve the issue. I have suggested using a script to reboot the Server Early Monday morning but IT is bent on only a manual reboot. 

Thanks,

Larry    

View solution in original post

0 Kudos
3 Replies
JonathanQuinn
Esri Notable Contributor

Are you interested in rebooting the machine or just the ArcGIS Server Windows service?  You can use the subprocess module for just about anything you can do through the command line.  For example, to stop the ArcGIS Server Windows service:

import subprocess

try:
    result = subprocess.check_output("net stop \"ArcGIS Server\"",stderr=subprocess.STDOUT)
    print(result)
except subprocess.CalledProcessError as e:
    print("Failed - {}".format(e.output))‍‍‍‍‍‍‍

When I need to do stuff like that, I usually use a function:

def submitCommand(command):
    try:
        codec = 'utf-8'
        result = subprocess.check_output(command,stderr=subprocess.STDOUT)
        success = True
    except subprocess.CalledProcessError as e:
        result = e.output
        success = False
    except:
        result = traceback.format_exc()
        success = False
    if not isinstance(result,str):
        result = result.decode(codec)
    return success, result‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I can then just call the function like:

success, result = submitCommand("net STOP \"ArcGIS Server\"")
print(success,result)
success, result = submitCommand("net START \"ArcGIS Server\"")
print(success,result)‍‍‍‍

You'll just need logic to handle the response and a failure.

LarryAdgate
Occasional Contributor

Hi Jonathan, typically Monday morning I arrive at the office to inspect all my Web Services and they are all offline. As a remedy, I submit a request to IT to reboot the Enterprise Server and that seems to resolve the issue. I have suggested using a script to reboot the Server Early Monday morning but IT is bent on only a manual reboot. 

Thanks,

Larry    

0 Kudos
JonathanQuinn
Esri Notable Contributor

I'd argue that the best thing to do would be to troubleshoot, (possible with Support), why your services are offline. Not sure if you've done a bit of that already.  What errors or behavior do you see?