CSIRO-enviro-informatics/registry-config-base

Logrotation isn't working

Opened this issue · 1 comments

Log rotation isn't working correctly at least for nginx.

Multiple issues

  • Logrotate doesn't seem to be able to properly signal and restart nginx and thus it keeps writing to old logs e.g never writes to a fresh access.log and continues writing to a renamed access.log.1
  • The processes writing to the log file maybe need the /var/log/nginx directory owned by www-data

In a local installation two changes appear to work

  1. changing /etc/logrotate.d/nginx to
/var/log/nginx/*.log {  
        daily  
        missingok  
        rotate 52  
        compress  
        delaycompress  
        notifempty  
        copytruncate  
        sharedscripts  
        prerotate  
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \  
                        run-parts /etc/logrotate.d/httpd-prerotate; \  
                fi \  
        endscript   
        postrotate  
                invoke-rc.d nginx rotate >/dev/null 2>&1  
        endscript  
}  

because copytruncate bypasses issues with create
2. chmod www-data /var/log/nginx

docker file needs to be updated with these changes, changes tested and other log rotation checked

Tested fix in locally deployed instance and merged but will wait for redeployment into prod to ensure this is working before closing this issue