mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-18 07:52:56 +01:00
92f2069627
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.
15 lines
685 B
Bash
Executable file
15 lines
685 B
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Prefixes all lines on stdout and stderr with the process name (as determined by
|
|
# the SUPERVISOR_PROCESS_NAME env var, which is automatically set by Supervisor).
|
|
#
|
|
# Usage:
|
|
# prefix-log command [args...]
|
|
#
|
|
|
|
# '-W interactive' is a `mawk` extension which disables buffering on stdout and sets line-buffered reads on
|
|
# stdin. The effect is that the output is flushed after each line, rather than being batched, which helps reduce
|
|
# confusion due to to interleaving of the different processes.
|
|
exec 1> >(awk -W interactive '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0 }' >&1)
|
|
exec 2> >(awk -W interactive '{print "'"${SUPERVISOR_PROCESS_NAME}"' | "$0 }' >&2)
|
|
exec "$@"
|