Use*_*Cat 6 php nginx supervisord laravel docker
我试图将 php-fpm7 日志显示到通过 nginx 和 supervisord 运行的标准输出中。supervisord 标准输出显示以下消息:
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"
Run Code Online (Sandbox Code Playgroud)
终端中什么也没有显示,但服务用数据回答了请求。
这是我的配置:
docker-compose-dev.yml
services:
# web server
web:
build: .
working_dir: /app
network_mode: bridge
command: supervisord
[...]
Run Code Online (Sandbox Code Playgroud)
文件
services:
# web server
web:
build: .
working_dir: /app
network_mode: bridge
command: supervisord
[...]
Run Code Online (Sandbox Code Playgroud)
配置文件
FROM alpine
RUN apk update && \
apk add bash curl openssh git supervisor nginx php7 \
[...other dependencies...]
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
# Mount Source code
COPY ./src /app
WORKDIR /app
# permission needed by lumen
RUN chmod -R 777 /app/storage/
RUN composer -v install
EXPOSE 80
CMD ["supervisord"]
Run Code Online (Sandbox Code Playgroud)
主管-lemp.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
[...]
Run Code Online (Sandbox Code Playgroud)
配置文件
[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
Run Code Online (Sandbox Code Playgroud)
logging.php (src/config)
http {
[...]
access_log /dev/stdout;
error_log /dev/stdout info;
[...]
}
Run Code Online (Sandbox Code Playgroud)
报价控制器.php
<?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',
],
],
],
];
Run Code Online (Sandbox Code Playgroud)
我启动容器的方式是这样使用的docker-compose:
docker-compose -f docker-compose-dev.yml up --build
Run Code Online (Sandbox Code Playgroud)
我无法理解发生了什么并弄清楚如何诊断问题。
提前致谢。
| 归档时间: |
|
| 查看次数: |
1016 次 |
| 最近记录: |