When sending an e-mail from an Input that is incrementally polling an ArcGIS Server service, one should be cautious when rebooting the GeoEvent server. Rebooting the server will cause the Poll an ArcGIS Server for Features input to start polling all features again. This will result in dozens, hundreds, or even thousands of e-mails sent if the Send An Email output is running. This document will walk you through how to prevent this from happening by executing a python script that will stop all, or specified, outputs at server shutdown.
1. If wanting to stop only a select number of GeoEvent outputs, you will need to obtain the names of each output. The name is a GUID that can be obtained from the GeoEvent Admin Directory. Ex: https://geoevent.esri.com:6143/geoevent/admin
Once logged in, click on Outputs at the top, then click on the GeoEvent Output. The Name will be listed there:
Open the attached Stop All GeoEvent Outputs.py script. Under the # Variables section, set the stopAllOutputs to False and update the outputs with each name copied from the GeoEvent Admin Directory. Ex:
2. If wanting to stop all GeoEvent outputs, set the stopallOutputs variable to True:
3. Update the remaining variables in the python script. Below is an explanation of each.
username = username to connect to GeoEvent Manager
password = username’s password
geoeventServer = fully qualified domain name of the server GeoEvent is installed on
federated = specify True if GeoEvent is federated with Portal, specify False if GeoEvent is not federated with Portal
portalServer = fully qualified domain name of the server Portal is installed on. This is only required if federated variable is set to True. This cannot be the DNS if using one
stopAllOutputs = set to True to stop all outputs, set to False to stop a select amount
outputs = list of output names to stop. This is only required if stopallOutputs variable is set to False
4. On the GeoEvent Server, open Local Group Policy Editor by going to Start > Run > gpedit.msc
5. Navigate to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown)
6. Double-click Shutdown
7. Under the Scripts tab click Add
8. For Script Name browse to the python executable (python.exe) under the ArcGIS Server installation. Ex:
C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe
9. For Script Parameters enter the path to the Stop All GeoEvent Outputs.py python script
10. Click OK and then OK again
When the server is rebooted the python script will be executed and stop the GeoEvent outputs. After the server is started, GeoEvent will start polling all features in the ArcGIS Server service you have specified for the Poll an ArcGIS Server for Features inputs. However, since the outputs are not started you will not be sent any e-mails.
Once the inputs are finished polling the ArcGIS Server services the Send An Email output(s) they are sending events to can be started. Now, an e-mail will only be sent on the next incremental update.
This worked like a charm! One of the biggest issues we ran across with restarting GeoEvent is the amount of emails that would be sent. Since we use a managed services company to maintain our servers, having this script run in the background will help alleviate the restart headache. However, you still have to be careful when restarting the outputs by making double sure the inputs are done receiving data. Thank you, @JakeSkinner!