# DO NOT EDIT - This file is being maintained by Chef

<%= node[:web][:log_directory] %>/*.log {
  daily
  missingok
  rotate 7
  compress
  delaycompress
  notifempty
  create 0660 rails rails
  sharedscripts
  postrotate
<% if File.directory?("#{node[:web][:base_directory]}/rails") -%>
    PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app --ignore-app-not-running --name rails > /dev/null
<% end -%>
<% if File.directory?("#{node[:web][:base_directory]}/gpx-import") -%>
    /bin/systemctl try-reload-or-restart gpx-import
<% end -%>
<% if File.directory?("#{node[:web][:base_directory]}/cgimap") -%>
    /bin/systemctl reload cgimap
    /usr/bin/rsync --preallocate <%= node[:web][:log_directory] %>/cgimap.log.2.gz ironbelly::logs/www.openstreetmap.org/cgimap-<%= node[:hostname] %>-`date -d "-2 days" +%Y-%m-%d`.gz
<% end -%>
  endscript
}

# DO NOT EDIT - This file is being maintained by Chef

<%= node[:web][:log_directory] %>/*.log {
  daily
  missingok
  rotate 7
  compress
  delaycompress
  notifempty
  create 0660 rails rails
  sharedscripts
  postrotate
<% if File.directory?("#{node[:web][:base_directory]}/rails") -%>
    /bin/sleep 30
    PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app --ignore-app-not-running --name rails > /dev/null
<% end -%>
<% if File.directory?("#{node[:web][:base_directory]}/gpx-import") -%>
    /bin/systemctl try-reload-or-restart gpx-import
<% end -%>
<% if File.directory?("#{node[:web][:base_directory]}/cgimap") -%>
    /bin/systemctl reload cgimap
    /usr/bin/rsync --preallocate <%= node[:web][:log_directory] %>/cgimap.log.2.gz ironbelly::logs/www.openstreetmap.org/cgimap-<%= node[:hostname] %>-`date -d "-2 days" +%Y-%m-%d`.gz
<% end -%>
  endscript
}

Add a short delay when rotating passenger logs
Add a short delay when rotating passenger logs

If the machine is idle then we may try and rotate the passenger
logs very quickly after the apache logs, in which case apache can
still be reloading which breaks the passenger log rotation.
