2022-04-27 16:39:41 +03:00
|
|
|
#!/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...]
|
|
|
|
#
|
|
|
|
|
2024-03-13 20:21:37 +03:00
|
|
|
# '-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)
|
2022-04-27 16:39:41 +03:00
|
|
|
exec "$@"
|