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?

  • Windows will tell you if a service is running. Are you looking to see if the service is responsive? – Vince Mar 12 '15 at 11:54
  • I meant MapServices in AGS, not Windows services.Sorry – Robert Buckley Mar 12 '15 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 Mar 12 '15 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. – Richard Morgan Mar 12 '15 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 Mar 12 '15 at 13:23

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: 

#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, privacy policy and cookie policy

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