From b30cce950ae773a0c424df27dcc183ffb0602a95 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Sep 2026 20:23:25 +0800 Subject: [PATCH] fix(docker): mirror tinode's own log output to stdout Confirmed live: /var/log/tinode.log-only redirection meant Loki never received a single real tinode runtime log line (election, rehash, connection, error output) since the container started -- Promtail collects standard container stdout/stderr, not files written inside the container. Every Pod's collected log was just this script's own "NO_DB_INIT=true: skipping..." init line, nothing from tinode itself. Now more consequential with native Cluster enabled: failover/rehash state transitions were completely invisible to the normal Grafana/Loki monitoring path, visible only via manual kubectl exec. tee mirrors to both stdout (collected) and the file (still readable via kubectl exec). PIPESTATUS[0] is required since a bare $? after a pipe would report tee's exit status, not tinode's -- which also let this drop the now-redundant "tail last 200 lines to stderr on crash" block, since the full live stream already went to stdout throughout the run. Co-Authored-By: Claude Sonnet 5 --- docker/tinode/entrypoint.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docker/tinode/entrypoint.sh b/docker/tinode/entrypoint.sh index c2d98a0..5f59388 100644 --- a/docker/tinode/entrypoint.sh +++ b/docker/tinode/entrypoint.sh @@ -188,11 +188,12 @@ fi args=("--config=${CONFIG}" "--static_data=$STATIC_DIR" "--cluster_self=$CLUSTER_SELF" "--pprof_url=$PPROF_URL") -# Run the tinode server. Mirror the captured stderr to container logs on exit so -# CrashLoopBackOff pods expose the actual startup failure via kubectl logs. -./tinode "${args[@]}" 2>> /var/log/tinode.log -status=$? -if [ "$status" -ne 0 ] && [ -s /var/log/tinode.log ]; then - tail -200 /var/log/tinode.log >&2 -fi -exit "$status" +# Run the tinode server, mirroring output to both stdout (so kubectl logs/Promtail's +# standard container-log collection actually sees it -- confirmed live that the old +# file-only redirect meant Loki never received a single real tinode log line, only +# this script's own earlier init-db output) and the log file (kept for exec-based +# inspection, e.g. `kubectl exec ... -- cat /var/log/tinode.log`). PIPESTATUS[0] is +# required here: with output piped through tee, a bare $? would report tee's exit +# status (almost always 0) instead of tinode's. +./tinode "${args[@]}" 2>&1 | tee -a /var/log/tinode.log +exit "${PIPESTATUS[0]}"