Select to view content in your preferred language

Can you use Python to stop ArcGIS Enterprise Service

1380
6
Jump to solution
02-16-2023 01:38 PM
MDavis
by
Emerging Contributor

MS Services.jpg

 Is it possible to use Python to stop the ArcGIS Service so you could successfully delete a FGDB with running map services completely and copy a new one in it's place with same name.  See the attached image for what I am referring.    

0 Kudos
1 Solution

Accepted Solutions
mody_buchbinder
Frequent Contributor

This has nothing to do with esri libraries.

You can do it with standard python libraries.

For example: https://stackoverflow.com/questions/46595845/python-command-to-stop-and-start-windows-services

I have a script that takes the machine out of load balancing, stop the service, replace directories (FGDB is just a directory) and then return everything. The script must run on the machine itself in order to take it out the load balancing.

Sorry I cannot share it but it is very simple.

Have fun

View solution in original post

0 Kudos
6 Replies
MichaelVolz
Esteemed Contributor

How about a truncate and append of feature classes in the FGDB so the services would not need to be stopped?

0 Kudos
MDavis
by
Emerging Contributor

That is what we are doing now. This is a dual Server setup for load balancing and the objectIDs do not match after the truncate and append script runs on each Server . This was not an issue until we started using the feature service in an AGOL application. The AGOL app must cache the ObjectID and if you identify another feature after an initial identify the different ObjectIDs cause strange behavior. 

0 Kudos
jcarlson
MVP Esteemed Contributor

You can do it through the ArcGIS Python API. Check out the arcgis.gis.server.Service section of the docs, where you'll see start and stop are both methods. So you could have a script stop the service, do whatever, then start it back up.

- Josh Carlson
Kendall County GIS
0 Kudos
MDavis
by
Emerging Contributor

Thank you I will check this out and let you know if this solves the problem. I appreciate the response.

0 Kudos
mody_buchbinder
Frequent Contributor

This has nothing to do with esri libraries.

You can do it with standard python libraries.

For example: https://stackoverflow.com/questions/46595845/python-command-to-stop-and-start-windows-services

I have a script that takes the machine out of load balancing, stop the service, replace directories (FGDB is just a directory) and then return everything. The script must run on the machine itself in order to take it out the load balancing.

Sorry I cannot share it but it is very simple.

Have fun

0 Kudos
MDavis
by
Emerging Contributor

Thank you I think this is what I am after. I appreciate you taking the time to answer. 

0 Kudos