【问题标题】:supervisord disable log files or use logfile=/dev/stdoutsupervisord 禁用日志文件或使用 logfile=/dev/stdout
【发布时间】:2018-01-20 14:16:14
【问题描述】:
[supervisord]
nodaemon=true
logfile=/dev/stdout
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor

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

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

【问题讨论】:

    标签: docker supervisord


    【解决方案1】:

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

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

    然后将每个托管进程的日志发送到标准输出文件描述符/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
    

    【讨论】:

    • 这可行,但 [supervisord] 的标准输出日志现在将在控制台中显示两次
    • 啊当然,因为nodaemon 已经在那里登录了。改为发送至/dev/null
    • 它发生在我身上(两次登录控制台)。我必须发送什么给/dev/null? @马特谢谢
    • @loretoparisi logfile=/dev/null for supervisord(答案已更新以包括在之前的 cmets 之后)
    • @Matt 在我的案例中感谢它不起作用在这里查看我的配置stackoverflow.com/q/56875104/758836
    【解决方案2】:

    您只需删除 supervisord.conf 中的 logfile,当您输入 docker logs <container_id> --tail=100 -f 时,每个日志都将显示为容器日志

    【讨论】:

    • 如果我删除 logfile=... 将应用默认值并在工作目录中创建一个日志文件
    猜你喜欢
    • 2012-05-19
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    • 2016-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    相关资源
    最近更新 更多