Monday, 25 November 2019

Client closed connection while waiting for request In supervidord when trying to log with monolog in Lumen

Im trying to show the php-fpm7 logs into the stdout running throught nginx and supervisord. The supervisord stdout show the message:

web_1| 2019-11-22 21:52:30,742 DEBG 'nginx' stdout output:
web_1| 2019/11/22 21:52:30 [info] 10#10: *1 client closed connection while waiting for request, client: 10.11.12.13, server: 0.0.0.0:80
web_1| 2019-11-22 21:52:31,481 BLAT read event caused by <POutputDispatcher at 140523539721320 for <Subprocess at 140523539815888 with name nginx in state RUNNING> (stdout)>
web_1| 10.11.12.13 - - [22/Nov/2019:21:52:31 +0000] "GET /offers/all HTTP/1.1" 500 24984 "-" "PostmanRuntime/7.19.0"

And nothing is shown in the terminal, but the service respond the request with data.

Here is my configuration:

docker-compose-dev.yml

services:
  # web server
  web:
    build: .
    working_dir: /app
    network_mode: bridge
    command: supervisord
    [...]

dockerfile

FROM alpine
[...]
COPY ./config/supervisord.conf /etc
COPY ./config/supervisor-lemp.conf /etc/supervisor/conf.d/

RUN mkdir -p /var/log/supervisor/

# Nginx configuration
COPY ./config/default /etc/nginx/sites-enabled/
COPY ./config/nginx.conf /etc/nginx/

# PHP7 Configuration
COPY ./config/www.conf /etc/php7/php-fpm.d/www.conf
[...]

supervisord.conf

[...]
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
nodaemon=true
loglevel=blather
[...]

supervisor-lemp.conf

[program:nginx]
command=nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:php-fpm7]
command=php-fpm7 --nodaemonize
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

nginx.conf

http {
    [...]
    access_log /dev/stdout;
    error_log /dev/stdout info;
    [...]
}

logging.php (src/config)

<?php
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\StreamHandler;

return [
    'default' => env('LOG_CHANNEL', 'single'),

    'channels' => [
        'single' => [
            'driver' => 'monolog',
            'name' => 'offer-service-log',
            'handler' => StreamHandler::class,
            'formatter' => JsonFormatter::class,
            'with' => [
                // 'stream' => storage_path('logs/lumen.log'),
                'stream' => 'php://stdout',
            ],
        ],
        'stdout' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => JsonFormatter::class,
            'with' => [
                'stream' => 'php://stdout',
            ],
        ],
    ],
];

OfferController.php

public function all(Request $request): JsonResponse
{
    Log::emergency('Im a log entry');

    throw new Exception("Hello");
    // [...]
}

I can't understand what is happening



from Client closed connection while waiting for request In supervidord when trying to log with monolog in Lumen

No comments:

Post a Comment