Listen to any published recently service on ArcGIS Server

487
13
11-27-2017 11:38 PM
MarkMindlin_idea
New Contributor II

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.

0 Kudos
13 Replies
RandallWilliams
Esri Regular Contributor

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.

0 Kudos
MarkMindlin
Occasional Contributor III

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.

0 Kudos
RandallWilliams
Esri Regular Contributor

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 

MarkMindlin_idea
New Contributor II

Thanks Randall,

Could you please send a link to list of log codes includes 23840.

0 Kudos
JonathanQuinn
Esri Frequent Contributor

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:

{
    "lifecycleinfos": [{
        "user": "",
        "timestamp": 1499448691252,
        "type": "created"
    }, {
        "user": "",
        "timestamp": 1499448691270,
        "type": "started"
    }, {
        "user": "admin",
        "timestamp": 1511979284702,
        "type": "stopped"
    }],
    "lastmodified": 1511979284702
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

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.

MarkMindlin_idea
New Contributor II

Thanks Jonathan,

But the API you provided /lifecyclesinfo

doesn't work

Should we switch on something on the service?

0 Kudos
JonathanQuinn
Esri Frequent Contributor

It should be available already.  Can you describe what you mean by doesn't work?

0 Kudos
MarkMindlin_idea
New Contributor II

Sorry, but your link returns

ERROR

The requested URL could not be retrieved

We have the service

public/NSW_Administrative_Boundaries (MapServer) 

We tried to apply your sintax /lifecyclesinfo

"http://maps.six.nsw.gov.au/arcgis/rest/services/public/NSW_Administrative_Boundaries/MapServer/lifecyclesinfo"

It does not work.

0 Kudos
JonathanQuinn
Esri Frequent Contributor

You access the lifecyclesinfo page through the Admin API, not the REST directory:

http://server.domain.com:6080/arcgis/admin/services/SampleWorldCities.MapServer/lifecycleinfos

0 Kudos