mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-13 02:44:53 +02:00
fix: Ensure main log file is tailed from the start (#4146)
Co-authored-by: Casper <casperklein@users.noreply.github.com>
This commit is contained in:
parent
2f8ad142ec
commit
526fd64d11
2 changed files with 10 additions and 3 deletions
|
@ -194,10 +194,16 @@ fi
|
|||
# marker to check if container was restarted
|
||||
date >/CONTAINER_START
|
||||
|
||||
# Container logs will receive updates from this log file:
|
||||
MAIN_LOGFILE=/var/log/mail/mail.log
|
||||
# NOTE: rsyslogd would usually create this later during `_start_daemons`, however it would already exist if the container was restarted.
|
||||
touch "${MAIN_LOGFILE}"
|
||||
# Ensure `tail` follows the correct position of the log file for this container start (new logs begin once `_start_daemons` is called)
|
||||
TAIL_START=$(( $(wc -l < "${MAIN_LOGFILE}") + 1 ))
|
||||
|
||||
[[ ${LOG_LEVEL} =~ (debug|trace) ]] && print-environment
|
||||
_start_daemons
|
||||
|
||||
# Container start-up scripts completed. `tail` will now pipe the log updates to stdout:
|
||||
_log 'info' "${HOSTNAME} is up and running"
|
||||
|
||||
touch /var/log/mail/mail.log
|
||||
exec tail -Fn 0 /var/log/mail/mail.log
|
||||
exec tail -Fn "+${TAIL_START}" "${MAIN_LOGFILE}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue