Hi,
We are thinking what approach could be to handle event of publishing (successfully) a service on ArcGIS Server. Could it be done with a server extension? How?
ArcGIS Server 10.5.1. (No ArcGIS Portal)
Any help please.
Can you elaborate a bit on what specifically you'd like to achieve? I'm unsure there's enough information to provide guidance at this point.
We want to run a Python script/executable (on a server where a ArcGIS Server installed) every time any service published (successfully) on the ArcGIS Server. We have no ArcGIS Portal.
An approach could be to periodically run a quick query on the logs using the admin API , looking for log code 23840 (service published). Dump the datestamps in a file, then do a diff/compare against a file created from a previous run. If the result of the compare between the 2 files = false, run the script.
The response to the log query would be similar to the following.
{ "type": "INFO", "message": "Service published [name: 123123123123123; type: MapServer].", "time": 1511902237075, "source": "System/PublishingToolsEx.GPServer", "machine": "machine.domain.COM", "user": "0123456789ABCDEF::someuser", "code": 23840, "elapsed": "", "process": "24509", "thread": "112", "methodName": "pubSD.Execute" }, { "type": "INFO", "message": "Service published [name: ausmap_WFL1; type: FeatureServer].", "time": 1509544574338, "source": "System/PublishingTools.GPServer", "machine": "machine.domain.COM", "user": "someuser", "code": 23840, "elapsed": "", "process": "19996", "thread": "73", "methodName": "pubSD.Execute" },
Example: Query the ArcGIS Server logs—Documentation (10.3 and 10.3.1) | ArcGIS for Server
Perhaps you can look at the lifecyclesinfo for each service:
http://server.domain.com:6080/arcgis/admin/services/SampleWorldCities.MapServer/lifecycleinfos
This will return when the service was created and last stopped, started, or edited:
<SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"lifecycleinfos"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"user"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"timestamp"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="number token">1499448691252</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"created"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"user"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"timestamp"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="number token">1499448691270</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"started"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"user"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"admin"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"timestamp"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="number token">1511979284702</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"stopped"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"lastmodified"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="number token">1511979284702</SPAN> <SPAN class="punctuation token">}</SPAN>
Potentially, you can run your script every X minutes and then loop through all services and check whether the service has been created within the last X minutes.
Thanks Jonathan,
But the API you provided /lifecyclesinfo
doesn't work
Should we switch on something on the service?
Thanks Randall,
Could you please send a link to list of log codes includes 23840.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.