AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1054459
Accepted
Guerrilla
Guerrilla
Asked: 2021-02-21 21:30:49 +0800 CST2021-02-21 21:30:49 +0800 CST 2021-02-21 21:30:49 +0800 CST

Supervisord 服务未输出到 docker-compose 控制台

  • 772

我有一个 docker 容器,它在其中运行多个服务。我希望每个服务都将其输出发送到控制台。这是一个开发容器,所以我想在工作时查看所有输出。

我试过这个文件:

[supervisord]
nodaemon=true
 
[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
 
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
priority=900
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
username=www-data
autorestart=true
autostart=true

[program:php-fpm]
command=/usr/sbin/php-fpm7.4 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=5


[program:memcached]
command=/usr/bin/memcached -u root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=200

但它只输出supervisord消息,而不是来自服务的消息。我看到另一个线程向其中发送日志消息,/dev/fd/1所以我也尝试了,但没有成功。

stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

我的基础镜像是 ubuntu 20.04。

为什么我不能将服务日志消息输入控制台?

docker supervisord stdout
  • 1 1 个回答
  • 1891 Views

1 个回答

  • Voted
  1. Best Answer
    Jacob Evans
    2021-02-24T20:52:39+08:002021-02-24T20:52:39+08:00

    首先,不要使用 supervisord 和 docker,选择一个或另一个,如果您使用的是 docker,请使用 docker compose 并使用 docker 拆分每个服务来控制进程,但如果您无论如何都要这样做.. . 我启动了主管supervisord -n并更新了我的 nginx 配置以将日志发送到 /dev/stderr 和 /dev/stdout 并且一切都按预期工作。nginx的启动命令由supervisord发送到/dev/stdout,nginx日志发送到nginx配置的地方,nginx启动参数只能配置error_log,具体链接见下文。

    root@6534bf4b8d3c:/# supervisord -n
    /usr/lib/python3/dist-packages/supervisor/options.py:470: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
      self.warnings.warn(
    2021-02-23 23:54:30,673 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
    2021-02-23 23:54:30,674 INFO Included extra file "/etc/supervisor/conf.d/guerrilla.conf" during parsing
    2021-02-23 23:54:30,676 INFO RPC interface 'supervisor' initialized
    2021-02-23 23:54:30,676 CRIT Server 'unix_http_server' running without any HTTP authentication checking
    2021-02-23 23:54:30,676 INFO supervisord started with pid 5239
    2021-02-23 23:54:31,678 INFO spawned: 'nginx' with pid 5241
    2021-02-23 23:54:32,686 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
    127.0.0.1 - - [23/Feb/2021:23:54:35 -0500] "GET / HTTP/1.1" 200 612 "-" "curl/7.68.0"
    

    sshd 日志记录

    nginx 日志记录

    php-fpm 日志记录

    memcached 日志记录(详细)

    • 2

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve