Skip to content

Commit 92f2069

Browse files
authored
Multi-worker-docker-container: disable log buffering (#16919)
Background: we have a `matrixdotorg/synapse-workers` docker image, which is intended for running multiple workers within the same container. That image includes a `prefix-log` script which, for each line printed to stdout or stderr by one of the processes, prepends the name of the process. This commit disables buffering in that script, so that lines are logged quickly after they are printed. This makes it much easier to understand the output, since they then come out in a natural order.
1 parent 9b5eef9 commit 92f2069

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

changelog.d/16919.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Multi-worker-docker-container: disable log buffering.

docker/prefix-log

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# prefix-log command [args...]
88
#
99

10-
exec 1> >(awk '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0}' >&1)
11-
exec 2> >(awk '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0}' >&2)
10+
# '-W interactive' is a `mawk` extension which disables buffering on stdout and sets line-buffered reads on
11+
# stdin. The effect is that the output is flushed after each line, rather than being batched, which helps reduce
12+
# confusion due to to interleaving of the different processes.
13+
exec 1> >(awk -W interactive '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0 }' >&1)
14+
exec 2> >(awk -W interactive '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0 }' >&2)
1215
exec "$@"

0 commit comments

Comments
 (0)