主管禁用日志文件或使用 Logfile=/dev/stdout


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

当我这样做时,这个主管会崩溃,因为它无法在/dev/stdout 中寻找

如何禁用在我的 docker 容器中创建任何日志文件的主管?

对于主主管,nodaemon将导致日志转到stdout

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

然后将每个托管进程的日志发送到 stdout 文件描述符/dev/fd/1

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

或者,如果您希望将 stderr 保留在不同的流上:

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

我遇到了同样的问题,所以我检查了主管文档,找到的最佳方法是:

[program:myservice]
command=/usr/local/bin/myservice.sh
autostart=true
autorestart=true
logfile_maxbytes=0
logfile_backups=0

就我而言,我保留了值为 3 和最大字节数为 10000000 的logfile_backup,因为我需要这个,我希望能帮助某人。

您只需删除 supervisord.conf 中的logfile,当您输入docker logs <container_id> --tail=100 -f

最新更新