/opt/osstech/var/log/unicornidm/unicornidm.log
{
    rotate 27
    weekly
    olddir old
    missingok
    notifempty
    # Delay compression of the youngest rotated log file because
    # old processes (uWSGI workers) may continue to write logs to
    # it until gracefully restarted.
    delaycompress
    # This log file is reopend by Python logging.handlers.WatchedFileHandler
    # when a new log message is arrived after rotation.
    su unicornidm unicornidm
}

/opt/osstech/var/log/unicornidm/uwsgi.log
{
    rotate 27
    weekly
    olddir old
    missingok
    notifempty
    delaycompress
    su unicornidm unicornidm
    postrotate
        exec /bin/setpriv \
            --no-new-privs \
            --reuid $(id -u unicornidm) \
            --regid $(id -g unicornidm) \
            --clear-groups \
        /bin/touch /opt/osstech/var/log/unicornidm/uwsgi.reopentrigger
    endscript
}

/opt/osstech/var/log/unicornidm/mongod.log
{
    rotate 27
    weekly
    olddir old
    missingok
    notifempty
    delaycompress
    su unicornidm unicornidm
    postrotate
        exec /bin/setpriv \
            --no-new-privs \
            --reuid $(id -u unicornidm) \
            --regid $(id -g unicornidm) \
            --clear-groups \
        /bin/sh -c '
            pid_file="/opt/osstech/var/lib/unicornidm/mongod.pid"
            [ -s "$pid_file" ] || exit 0
            pid=$(cat "$pid_file") || exit $?
            kill -USR1 "$pid" || exit $?
        '
    endscript
}
