Handle log rotation
As requested by @josegonzalez.
This commit is contained in:
1 parent
16e4001677
commit
69aba06361
1 file changed
+26
@@ -3,6 +3,9 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|||||||
source "$(dirname $0)/../common/functions"
|
source "$(dirname $0)/../common/functions"
|
||||||
|
|
||||||
DOKKU_RSYSLOG_FILTER=/etc/rsyslog.d/99-dokku.conf
|
DOKKU_RSYSLOG_FILTER=/etc/rsyslog.d/99-dokku.conf
|
||||||
|
DOKKU_LOGROTATE_FILE=/etc/logrotate.d/dokku
|
||||||
|
|
||||||
|
flag_rsyslog_needs_restart=n
|
||||||
|
|
||||||
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
|
if [[ ! -f "$DOKKU_EVENTS_LOGFILE" ]]; then
|
||||||
touch "$DOKKU_EVENTS_LOGFILE"
|
touch "$DOKKU_EVENTS_LOGFILE"
|
||||||
@@ -15,6 +18,29 @@ if [[ ! -f "$DOKKU_RSYSLOG_FILTER" ]]; then
|
|||||||
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
|
cat >"$DOKKU_RSYSLOG_FILTER" <<EOF
|
||||||
:syslogtag, contains, "dokku" $DOKKU_EVENTS_LOGFILE
|
:syslogtag, contains, "dokku" $DOKKU_EVENTS_LOGFILE
|
||||||
EOF
|
EOF
|
||||||
|
flag_rsyslog_needs_restart=y
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$DOKKU_LOGROTATE_FILE" ]]; then
|
||||||
|
cat >"$DOKKU_LOGROTATE_FILE" <<EOF
|
||||||
|
$DOKKU_EVENTS_LOGFILE {
|
||||||
|
daily
|
||||||
|
rotate 7
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
su syslog dokku
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
postrotate
|
||||||
|
reload rsyslog >/dev/null 2>&1 || true
|
||||||
|
endscript
|
||||||
|
create 664 syslog dokku
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
flag_rsyslog_needs_restart=y
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$flag_rsyslog_needs_restart" == "y" ]]; then
|
||||||
service rsyslog restart
|
service rsyslog restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user