Data Swap / Update for a Web Service

601
4
03-01-2022 10:22 AM
BenCochrane
New Contributor III

Hi,

I work for a local government and we run a number of web services that are used across the organisation.

One of the web services is a point feature class showing all the entries into our gazetteer. This layer is updated every night via python scripts created via model builder and ran through task scheduler on our server. There are three parts to this, the first part copies and replaces a table from the SQL database of the gazetter into our  "Vector" SDE database. The second part deletes the current point feature class that is built from this table and recreates a new copy from the table. The third part of this copies the newly created point feature class over onto the server which hosts our web app data. We have a dbo task set up to kill all connections to the "Vector" SDE database to ensure we dont encounter any locks ( this task runs at 5am so is unlikely to have anyone connected but this is an added layer of security ). 

 

If I am doing a manual dataswap I was always follow the practice of stopping the service before copying the new data intothe correct location, rename the existing data with _OLD as backup and it all works fine, I then restart the service. As I cant do this at 5am I have two options...

Can the above run and copy rename the data without stopping the service or will this cause issues?

 

If this is the case, is it possible to stop a particular service via a script in task scheduler and if this is the way to do it , can anyone point me in the correct direction for guidance on stopping /starting tasks via task scheduler?

 

thanks and I hope the above isnt too long winded and confusing

 

Ben

0 Kudos
4 Replies
MichaelVolz
Esteemed Contributor

If you perform a truncate and append process without modifying the table schema, then this operation can be done while the service is running (Recommended solution).

Is the service running in AGOL or Portal as you could you use the python API to stop the service with a minimal amount of code:

https://support.esri.com/en/technical-article/000019994

The python code sample stops services in the root ArcGIS Server directory, so the code would need to be modified to access services in child subfolders.

BenCochrane
New Contributor III

Hi Michael ,

 

Thanks for the reply. I am not aware of a "truncate and append" process, is this something that is done with a geoprocessing tool? 

 

The service is running in portal.

 

thanks

0 Kudos
berniejconnors
Occasional Contributor III

Google gave me this result - https://community.esri.com/t5/python-questions/start-stop-map-service-arcpy/td-p/270881

We do several automated updates that involve stopping and restarting a map service.  Please reach out and we can share a sample script with you.  geonb at snb dot ca

Bernie.

0 Kudos
TanuHoque
Esri Regular Contributor

I agree with that @MichaelVolz says. That said, if you really need to do what you said you would for some reasons, you can turn off the schema locking from your service setting that should allow you do data swapping without stopping the service.

That said, we always recommend users to be aware of what they are doing when they turn off data schema locking.

TanuHoque_0-1646163219469.png

 

0 Kudos