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
|
@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file. The format
|
|||
- Update logwatch `ignore.conf` to exclude Xapian messages about pending documents ([#4060](https://github.com/docker-mailserver/docker-mailserver/pull/4060))
|
||||
- `dovecot-fts-xapian` plugin was updated to `1.7.13`, fixing a regression with indexing ([#4095](https://github.com/docker-mailserver/docker-mailserver/pull/4095))
|
||||
- **Internal:**
|
||||
- The main `mail.log` which is piped to stdout via `tail` now correctly begins from the first log line of the active container run. Previously some daemon logs and potential warnings/errors were omitted. ([#4146](https://github.com/docker-mailserver/docker-mailserver/pull/4146))
|
||||
- Fixed a regression introduced in v14 where `postfix-main.cf` appended `stderr` output into `/etc/postfix/main.cf`, causing Postfix startup to fail ([#4147](https://github.com/docker-mailserver/docker-mailserver/pull/4147))
|
||||
|
||||
### CI
|
||||
|
|
|
@ -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…
Reference in New Issue