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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4abd6604d7
commit
b30cce950a
@@ -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]}"
|
||||
|
||||
Reference in New Issue
Block a user