supervisord: is it possible to redirect subprocess stdout back to supervisord?

偶尔善良 提交于 2019-12-12 16:12:33

问题


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.

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 ?


回答1:


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

Explanation:

  • 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 as stdout_logfile therefore causes supervisord 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.

For more information:

http://veithen.github.io/2015/01/08/supervisord-redirecting-stdout.html



来源:https://stackoverflow.com/questions/26192715/supervisord-is-it-possible-to-redirect-subprocess-stdout-back-to-supervisord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!