fix: use copytruncate in logrotate commands

While using create is more correct, logs in Dokku are considered ephemeral, and thus shouldn't be considered subject to the more comprehensive log retention standards one might require out of a logging system.

By switching to copytruncate, we can ensure that logs mounted from within containers do not have that matched the old settings (closes #6633) and cases where the log file is written by a user other than the one specified in the old logrotate settings (closes #4000).
This commit is contained in:
Jose Diaz-Gonzalez committed 2024-03-12 23:49:49 -04:00
1 parent c8afdb553d
commit 64cc239d5b
1 file changed
+16 -20
+16 -20
View File
@@ -16,24 +16,24 @@ trigger-events-install() {
# exits gracefully if the path already exists # exits gracefully if the path already exists
mkdir -m 775 -p "$DOKKU_LOGS_DIR" mkdir -m 775 -p "$DOKKU_LOGS_DIR"
case "$DOKKU_DISTRO" in case "$DOKKU_DISTRO" in
arch | debian | raspbian) arch | debian | raspbian)
chgrp dokku "$DOKKU_LOGS_DIR" chgrp dokku "$DOKKU_LOGS_DIR"
;; ;;
*) *)
chown syslog:dokku "$DOKKU_LOGS_DIR" chown syslog:dokku "$DOKKU_LOGS_DIR"
;; ;;
esac esac
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
touch "$DOKKU_EVENTS_LOGFILE" touch "$DOKKU_EVENTS_LOGFILE"
case "$DOKKU_DISTRO" in case "$DOKKU_DISTRO" in
arch | debian | raspbian) arch | debian | raspbian)
chgrp dokku "$DOKKU_EVENTS_LOGFILE" chgrp dokku "$DOKKU_EVENTS_LOGFILE"
;; ;;
*) *)
# chown syslog:root might not work on SUSE # chown syslog:root might not work on SUSE
chown syslog:dokku "$DOKKU_EVENTS_LOGFILE" chown syslog:dokku "$DOKKU_EVENTS_LOGFILE"
;; ;;
esac esac
chmod 664 "$DOKKU_EVENTS_LOGFILE" chmod 664 "$DOKKU_EVENTS_LOGFILE"
fi fi
@@ -56,16 +56,12 @@ EOF
cat >"$DOKKU_LOGROTATE_FILE" <<EOF cat >"$DOKKU_LOGROTATE_FILE" <<EOF
$DOKKU_LOGS_DIR/*.log { $DOKKU_LOGS_DIR/*.log {
daily daily
rotate 7
missingok missingok
notifempty rotate 7
su syslog dokku
compress compress
delaycompress delaycompress
postrotate notifempty
reload rsyslog &>/dev/null || true copytruncate
endscript
create 664 syslog dokku
} }
EOF EOF