Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

linux - Supervisord - Redirect process stdout to console

I am planning to run multiple processes using supervisor and please find my supervisord.conf file below:

[supervisord]

[program:bash]
command=xyz
stdout_logfile =/tmp/bash.log
redirect_stderr=true

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

I wish to redirect the stdout of the process named bash to supervisor console so that when i start supervisor using

/usr/bin/supervisord

command, i could see the child process logs. How can i do this ? I tried putting syslog for stdout_logfile attribute but it did not work.

question from:https://stackoverflow.com/questions/25195880/supervisord-redirect-process-stdout-to-console

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...