I have an nginx Unit+Php container with the following docker file
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
And If I run this, it works fine, index.php loads correctly. Now, I want to use supervisor to start a php script to run as daemon. This is a kafkaConsumer with a while loop. Below are the files
[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
And a simple php script for testing.
<?php
while(1){
sleep(3);
echo ".";
}
?>
However, If I add the following line to Dockerfile to start supervisor,
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Then, the daemon php script does start, but the php server (http://localhost/) stops responding, with the following message
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
Any help much appreciated.