supervisord:可以将subprocess stdout重定向到supervisord吗? [英] supervisord: is it possible to redirect subprocess stdout back to supervisord?
问题描述
我使用supervisord作为Docker容器的入口点,如 https:// docs中所述。 docker.com/articles/using_supervisord/ ,
我希望将所有日志写入stdout,以便我可以利用内置工具,如 docker logs
或systemd的日志,特别是如果在CoreOS上运行容器。
I'm using supervisord as the entry point for Docker containers as described in https://docs.docker.com/articles/using_supervisord/,
I want all logs to be written to stdout so I can take advantage of builtin tools like docker logs
or systemd's journal, especially if running the containers on CoreOS.
对于stderr,子进程有 redirect_stderr = true
可以将子进程stdout重定向到supervisord,而不是处理实际的日志文件?
for stderr there's redirect_stderr=true
option for subprocesses,
is it possible to redirect the subprocess stdout back to supervisord somehow and not deal with actual log files ?
推荐答案
你可以使用以下配置选项将程序的stdout重定向到主管的stdout:
You can redirect the program's stdout to supervisor's stdout using the following configuration options:
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
说明:
- 当进程打开
/ dev / fd / 1
(这是与/ proc / self / fd / 1
相同),系统实际上克隆了该进程的文件描述符#1(stdout)。因此,使用stdout_logfile
导致supervisord
将程序的标准重定向到自己的标准输出。 -
stdout_logfile_maxbytes = 0
禁用日志文件轮换显然对于stdout无效。不指定此选项将导致错误,因为默认值为50MB,并且管理员不够聪明,无法检测到指定的日志文件不是常规文件。
- When a process opens
/dev/fd/1
(which is the same as/proc/self/fd/1
), the system actually clones file descriptor #1 (stdout) of that process. Using this asstdout_logfile
therefore causessupervisord
to redirect the program's stdout to its own stdout. stdout_logfile_maxbytes=0
disables log file rotation which is obviously not meaningful for stdout. Not specifying this option will result in an error because the default value is 50MB and supervisor is not smart enough to detect that the specified log file is not a regular file.
有关详细信息:
http://veithen.github.io/2015/01/08/supervisord-redirecting-stdout.html
这篇关于supervisord:可以将subprocess stdout重定向到supervisord吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!