/opt/SIA/log/siawatchdog.log {
    missingok
    notifempty
    compress
    size 1M
    copytruncate
    # logrotate "su" is setuid/setgid, not sudo. Required for 775 root:www-data (#SIA-I962).
    su root www-data
    #Restart SIA watchdog to switch to the new log file
    postrotate
        # Native systemd service: no action needed (copytruncate + StandardOutput=append)
        if systemctl show -p FragmentPath "siawatchdog" 2>/dev/null | grep -q "/etc/systemd/system/\|/lib/systemd/system/"; then
            true
        # Generated unit from init.d: send SIGHUP to reopen log file
        elif systemctl show -p FragmentPath "siawatchdog" 2>/dev/null | grep -q "/run/systemd/generator"; then
            [ -f "/var/run/siawatchdog.pid" ] && kill -HUP $(cat "/var/run/siawatchdog.pid") 2>/dev/null
        # SysVinit system: restart service
        elif [ -x "/etc/init.d/siawatchdog" ]; then
            /etc/init.d/siawatchdog restart 2>/dev/null
        fi
    endscript
}
