supervisord disable log files or use logfile=/dev/

2020-07-06 06:32发布

问题:

[supervisord]
nodaemon=true
logfile=/dev/stdout
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor

When I do this supervisor will crash because it cannot seek in /dev/stdout

How can I disable supervisord creating any log files in my docker container?

回答1:

For the main supervisor, nodaemon will cause logs to go to stdout

[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0

Then send the logs for each managed process to the stdout file descriptor /dev/fd/1

[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

Or if you prefer to keep stderr on a different stream:

[program:x]
command=echo test
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0


回答2:

You can just remove the logfile in your supervisord.conf and every logs will show as container logs when you enter docker logs <container_id> --tail=100 -f