/opt/SIA/log/siashadowapi.log {
    missingok
    notifempty
    compress
    size 5M
    copytruncate
    dateext
    dateformat -%s
    su root root
    # restart ShadowAPI to switch to the new log file
    postrotate
        # Native systemd service: no action needed (copytruncate + StandardOutput=append)
        if systemctl show -p FragmentPath "siashadowapi" 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 "siashadowapi" 2>/dev/null | grep -q "/run/systemd/generator"; then
            [ -f "/var/run/siashadowapi.pid" ] && kill -HUP $(cat "/var/run/siashadowapi.pid") 2>/dev/null
        # SysVinit system: restart service
        elif [ -x "/etc/init.d/siashadowapi" ]; then
            /etc/init.d/siashadowapi restart 2>/dev/null
        fi
    endscript
}

