Esri / arcgis-cookbook

Chef cookbooks for ArcGIS
Apache License 2.0
297 stars 116 forks source link

recipe[arcgis-geoevent] cannot rerun #263

Closed thk70 closed 3 years ago

thk70 commented 3 years ago

The recipe for ArcGIS Geoevent is not perfect. First run is running okay, but If you rerun the recipe it fails: FATAL: Errno::ENOTEMPTY: directory[C:\ProgramData\Esri\GeoEvent-Gateway] (arcgis-geoevent::default line 95) had an error: Errno::ENOTEMPTY: Directory not empty @ dir_s_rmdir - C:\ProgramData\Esri\GeoEvent-Gateway

This also affects the uninstall recipe, because it doesn't clean the Geoevent directories, which again makes the install recipe fail. This makes it impossible to re-install the product.

Using Windows 2016, Esri Cookbooks 3.6.1, Chef Client 14.14.29

thk70 commented 3 years ago

During the rerun of the install recipe, the Service ArcGISGeoEvent is stopped, however the ArcGISGeoEventGateway is still running. This service is locking the files in "C:\ProgramData\Esri\GeoEvent-Gateway".

If I stop the ArcGISGeoEventGateway service manually, the recipe runs without error.

cameronkroeker commented 3 years ago

Hi @thk70,

This issue will be addressed in the next release of the cookbooks. We will add logic so that the ArcGISGeoEventGateway service gets stopped prior to deleting the directory.

Thanks, Cameron K.

MattoHopkins commented 3 years ago

Hey @cameronkroeker,

Just wanted to confirm the introduction of this? Hitting this error on first run as java.exe is still using that folder. Is it safe to add code in to stop the process?

Cheers

cameronkroeker commented 3 years ago

Hey @cameronkroeker,

Just wanted to confirm the introduction of this? Hitting this error on first run as java.exe is still using that folder. Is it safe to add code in to stop the process?

Cheers

Hi @MattoHopkins,

Yes, you can add the following snippet to the cookbooks/arcgis-geoevent/recipes/default.rb recipe (line 92):

arcgis_geoevent_geoevent 'Stop ArcGIS GeoEvent Server' do
  install_dir node['arcgis']['server']['install_dir']
  action :stop
end

So would look something like this:

arcgis_geoevent_geoevent 'Configure ArcGISGeoEvent service' do
  install_dir node['arcgis']['server']['install_dir']
  only_if { node['arcgis']['geoevent']['configure_autostart'] }
  action :configure_autostart  
end

arcgis_geoevent_geoevent 'Stop ArcGIS GeoEvent Server' do
  install_dir node['arcgis']['server']['install_dir']
  action :stop
end

if node['platform'] == 'windows'
  # Remove everything under C:\ProgramData\Esri\GeoEvent-Gateway before starting GeoEvent.
  directory "#{ENV['ProgramData']}\\Esri\\GeoEvent-Gateway" do
    recursive true
    action :delete
  end

  directory "#{ENV['ProgramData']}\\Esri\\GeoEvent-Gateway" do
    action :create
  end
end

arcgis_geoevent_geoevent 'Start ArcGIS GeoEvent Server' do
  install_dir node['arcgis']['server']['install_dir']
  action :start
end

This is how it will be fixed in the next release (v3.70) of the cookbooks.

Happy Automating, Cameron K.

MattoHopkins commented 3 years ago

Hey @cameronkroeker,

That still doesn't work unforunately. I've even added a two minute sleep (shown), thinking that perhaps the service needs a bit of time to turn off, but that didn't help either


  * arcgis_geoevent_geoevent[Configure ArcGISGeoEvent service] action configure_autostart
    * windows_service[ArcGISGeoEvent] action enable (up to date)
     (up to date)
  * arcgis_geoevent_geoevent[Stop ArcGIS GeoEvent Server] action stop
    * windows_service[ArcGISGeoEvent] action stop
      - stop service windows_service[ArcGISGeoEvent]

  * chef_sleep[120] action sleep
    - sleep 120 seconds
  * directory[C:\ProgramData\Esri\GeoEvent-Gateway] action delete

    ================================================================================
    Error executing action `delete` on resource 'directory[C:\ProgramData\Esri\GeoEvent-Gateway]'
    ================================================================================

    Errno::ENOTEMPTY
    ----------------
    Directory not empty @ dir_s_rmdir - C:\ProgramData\Esri\GeoEvent-Gateway

    Resource Declaration:
    ---------------------
    # In C:/Users/adm_matthew/.chef/local-mode-cache/cache/cookbooks/arcgis-geoevent/recipes/default.rb

    103:   directory "#{ENV['ProgramData']}\\Esri\\GeoEvent-Gateway" do
    104:     recursive true
    105:     action :delete
    106:   end
cameronkroeker commented 3 years ago

@MattoHopkins my apologies I totally forgot the other half of the fix! Need to also stop the GeoEvent Gateway service. Its only stopping GeoEvent Server service, so the Gateway Service is still running, locking the files, causing the deletion error.

https://github.com/Esri/arcgis-cookbook/blob/master/cookbooks/arcgis-geoevent/providers/geoevent.rb#L121-L126

action :stop do
  if node['platform'] == 'windows'
    service "ArcGISGeoEvent" do
      supports :status => true, :restart => true, :reload => true
      action :stop
    end

    service "ArcGISGeoEventGateway" do
      supports :status => true, :restart => true, :reload => true
      action :stop
    end

And also the start action:

https://github.com/Esri/arcgis-cookbook/blob/master/cookbooks/arcgis-geoevent/providers/geoevent.rb#L137-L143

action :start  do
  if node['platform'] == 'windows'
    service "ArcGISGeoEventGateway" do
      supports :status => true, :restart => true, :reload => true
      timeout 180
      action [:enable, :start]
    end

    service "ArcGISGeoEvent" do
      supports :status => true, :restart => true, :reload => true
      timeout 180
      action [:enable, :start]
    end
MattoHopkins commented 3 years ago

Thanks a ton! The addition to the start/stop action resolved it.

cameronkroeker commented 3 years ago

This issue has been addressed in cookbooks v370:

https://github.com/Esri/arcgis-cookbook/releases/tag/v3.7.0