1

I am using AGSSOM.exe to start and stop ArcGIS Server 10.0 MapServices. I would like to slightly adapt this script to first check if the services are running, and then to start them if they have stopped.

Does anyone know if this is possible and how?

5
  • Windows will tell you if a service is running. Are you looking to see if the service is responsive?
    – Vince
    Commented Mar 12, 2015 at 11:54
  • I meant MapServices in AGS, not Windows services.Sorry Commented Mar 12, 2015 at 11:57
  • I could also use an answer to this, we've been discussing a similar solution at work recently (as a better alternative to the current method, "wait until a user notices and complains")
    – Erica
    Commented Mar 12, 2015 at 11:58
  • Are you asking about trying to monitor the service? Looking at the source code for AGSSOM, sending a start command to already running service doesn't seem to error so you could just "start" your service and it will start if stopped or paused. Commented Mar 12, 2015 at 12:05
  • @Erica Building an alerting system is possible in any web-enabled language (Python, Java, C#, JavaScript, even 'C' if you're a glutton for punishment). All you need to know is the REST endpoint URL and the kind of notification.
    – Vince
    Commented Mar 12, 2015 at 13:23

1 Answer 1

1

This may work for you. This uses a combination of Python and the AGSSOM utility to create a list of the running map services and then stop any services in that list.

import os, subprocess 

#Get list of currently running map services 
stream = os.popen('D:\GIS\Admin\AGSSOMv10.0\AGSSOM.exe -list') 
mapservices = stream.readlines() 
lstStarted = [] 

for item in mapservices: 
    itemSplit = item.split(',') 
    if len(itemSplit) > 1: 
        if itemSplit[1].find("Started.") > -1: 
            lstStarted.append(itemSplit[0]) 



#Restart previously running map services 
for mapservice in lstStarted: 
    subprocess.call(['D:\GIS\Admin\AGSSOMv10.0\AGSSOM.exe', '-x', mapservice])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.