代码之家  ›  专栏  ›  技术社区  ›  aVC

使用supervisor时nginx单元php服务器停止响应

  •  0
  • aVC  · 技术社区  · 1 年前

    我有一个nginx Unit+Php容器,里面有以下docker文件

    FROM unit:1.32.1-php8.2
    RUN apt-get update && apt-get install -y supervisor
    EXPOSE 80
    WORKDIR /var/www/html/
    COPY config.json /docker-entrypoint.d/config.json
    

    如果我运行这个,它工作正常,index.php加载正确。现在,我想使用supervisor启动一个php脚本作为守护进程运行。这是一个带有while循环的kafkaConsumer。以下是文件

    [supervisord]
    nodaemon=true
    
    [program:nginx-unit]
    command=unitd --no-daemon
    stdout_logfile_maxbytes = 0
    stderr_logfile_maxbytes = 0
    stdout_logfile=/var/log/unit.log
    stderr_logfile=/var/log/unit.log
    autostart=true
    autorestart=true
    
    
    [program:kafkaTestConsumer]
    command=php /var/www/html/PhpScriptThatRunsContinuously.php
    autostart=true
    directory=/var/www/html/
    autorestart=true
    stdout_logfile=/dev/stdout
    stderr_logfile=/dev/stderr
    stdout_maxbytes=0 # need these lines due to [https://github.com/Supervisor/supervisor/issues/935][1]
    stderr_maxbytes=0
    stdout_logfile_maxbytes = 0
    stderr_logfile_maxbytes = 0
    

    以及一个用于测试的简单php脚本。

    <?php
    while(1){
        sleep(3);
        echo ".";
    }
    ?>
    

    但是,如果我在Dockerfile中添加以下行来启动supervisor,

    CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
    

    然后,守护进程php脚本确实会启动,但php服务器(http://localhost/)停止响应,并显示以下消息

    localhost didn’t send any data.
    ERR_EMPTY_RESPONSE
    

    非常感谢任何帮助。

    0 回复  |  直到 1 年前