Select to view content in your preferred language

Start/stop arcgis secure services Python 3

1749
2
06-30-2020 11:13 PM

Start/stop arcgis secure services Python 3

For anyone who is interested, here a Python 3 script that stops or starts all map services in the ROOT folder. It can be started with the following command:

"<arcgis install dir>\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe" <file location>\Start_stop_arcgis_services_in_folder_https_P3.py %1 %USER% %2 %PASS% %3 %SERV% %4 %MAP% %5 %STARTSTOP%

Any improvements are welcome of course

Attachments
Comments
MeleKoneya
Regular Contributor

Thank you for posting this!     I have been struggling to find a working solution for a while.    This is perfect.   

IanIce1
New Contributor III

This is great! I'm currently migrating old python 2 scripts to python 3 and spent way too much time trying to get it to work in Py 3 (after upgrading httplib, encoding, https, etc).  One thing I added to make it work for services in a folder was adding the actual folder variable in the servicesStartStop function:

def serviceStartStop(server, port, svc, folder, action, token):
# Build URL
url = "https://{}:{}/arcgis/admin".format(server, port)
requestURL = url + "/services/{}/{}/{}".format(folder, svc, action)

Otherwise it will raise an error saying "service.mapserver does not exist or operation is not supported"

Thank you!

Version history
Last update:
‎06-30-2020 11:13 PM
Updated by:
Contributors