错误消息 "Crit uncaptured python exception" 而 运行 supervisord on docker

Error message "Crit uncaptured python exception" while running supervisord on docker

我正在 docker 容器上尝试 supervisord 以尝试控制容器内的两个进程。现在,process1 每 10 秒键入一次“我是进程 1”,进程 2 键入“我是进程 2”。它们都是非常简单的 bash 脚本。

在 docker 日志中我遇到了这个错误:

2022-04-04T15:40:56.770705073Z I am process 1
2022-04-04T15:40:56.770775532Z 2022-04-04 15:40:56,770 CRIT uncaptured python exception, closing channel <POutputDispatcher at 140473979288352 for <Subprocess at 140473979288304 with name PROGRAM1 in state RUNNING> (stdout)> (<class 'OSError'>:[Errno 29] Illegal seek [/usr/lib/python3/dist-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|handle_read_event|281] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|record_output|215] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|_log|184] [/usr/lib/python3/dist-packages/supervisor/loggers.py|info|327] [/usr/lib/python3/dist-packages/supervisor/loggers.py|log|345] [/usr/lib/python3/dist-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3/dist-packages/supervisor/loggers.py|doRollover|264])
2022-04-04T15:41:06.761850899Z I am process 2
2022-04-04T15:41:06.761913329Z 2022-04-04 15:41:06,761 CRIT uncaptured python exception, closing channel <POutputDispatcher at 140473979378128 for <Subprocess at 140473979378224 with name PROGRAM2 in state RUNNING> (stdout)> (<class 'OSError'>:[Errno 29] Illegal seek [/usr/lib/python3/dist-packages/supervisor/supervisord.py|runforever|218] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|handle_read_event|281] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|record_output|215] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|_log|184] [/usr/lib/python3/dist-packages/supervisor/loggers.py|info|327] [/usr/lib/python3/dist-packages/supervisor/loggers.py|log|345] [/usr/lib/python3/dist-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3/dist-packages/supervisor/loggers.py|doRollover|264])

我的 Dockerfile 如下所示:

FROM debian:bullseye
WORKDIR /app
COPY . /app
COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN apt-get update && apt-get install -y  supervisor && apt-get install -y procps
#RUN apt-get install -y python3-pip && pip install supervisor-stdout
CMD ["/usr/bin/supervisord"]

我的 supervisord.conf 看起来像这样:

[supervisord]
nodaemon=true

[program:program1]
command=/bin/bash /app/process1.sh &
process_name=PROGRAM1
autostart=true
autorestart=true
priority=0
redirect_stderr=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr

[program:program2]
command=/bin/bash /app/process2.sh &
process_name=PROGRAM2
autostart=true
autorestart=true
priority=0
redirect_stderr=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr

这里发生了什么?我的配置有问题吗?

谢谢!

我知道是怎么回事了。您需要指定日志文件的最大大小为 0,因为主管无法在 /dev/stdout.

上写入文件

在每个节目中:

stdout_logfile_maxbytes = 0
stderr_logfile_maxbytes = 0

灵感:https://github.com/Supervisor/supervisor/issues/1412