# Openresty's logs, where its configuration actually writes them: relative
# `logs/` paths resolve against the prefix, /usr/local/openresty/nginx.
#
# This used to rotate /var/log/nginx/*.log and signal /var/run/nginx.pid -
# the system nginx's directory and pid file. Openresty writes to neither, so
# its own logs were never rotated at all and grew without limit, and on hosts
# that did log to /var/log/nginx it was never told to reopen, so it kept
# writing into the file that had just been rotated away. /var/log/nginx is
# also claimed by nginx-common's own logrotate stanza, which must not be
# duplicated here.
/usr/local/openresty/nginx/logs/*.log {
    daily
    rotate 14
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        # USR1 tells nginx to reopen its log files. The pid file is the one
        # openresty.service names.
        PID=/usr/local/openresty/nginx/logs/nginx.pid
        if [ -s "$PID" ]; then
            kill -USR1 "$(cat "$PID")"
        fi
    endscript
}
