# Rotation for xin's own log directory.
#
# A configuration that points error_log/access_log at nginx's paths is rotated
# by nginx's own logrotate file, which already exists on such a host; this
# covers /var/log/xin, which is the directory this package creates and owns.
#
# The postrotate signal goes to the broker, which is the process that owns the
# log file descriptors and the pid that does not change across a respawn.
# `xind -s reopen` is deliberately not used here: it is parsed and refused
# today (it needs the `pid` directive), so a postrotate calling it would fail
# on every rotation.
/var/log/xin/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 root adm
    sharedscripts
    postrotate
        if [ -d /run/systemd/system ]; then
            systemctl kill -s USR1 xin.service >/dev/null 2>&1 || true
        else
            pkill -USR1 -x xind >/dev/null 2>&1 || true
        fi
    endscript
}
