use*_*934 4 ruby-on-rails nginx supervisord docker
我在由supervisord 管理的docker 容器中运行nginx 和unicorn。
所以,supervisord就是docker命令。它反过来又产生 nginx 和 unicorn。Unicorn 通过套接字与 nginx 通信。nginx 监听 80 端口。
我还运行了一个 Logspout docker 容器,基本上通过监听 docker.sock 将所有 docker 日志通过管道传送到 papertrail。
问题是 nginx 不断向日志中写入数千条普通条目:
172.31.45.231 - - [25/May/2016:05:53:33 +0000] "GET / HTTP/1.0" 200 12961 0.0090
我正在尝试禁用它。
到目前为止我已经:
设置access_logs /dev/null;在nginx.conf和 vhost 文件中。
试图告诉supervisord停止记录请求
[程序:nginx] command=bash -c "/usr/sbin/nginx -c /etc/nginx/nginx.conf" stdout_logfile=/dev/null stderr_logfile=/dev/null
试图告诉supervisord将日志发送到syslog而不是stdout:
[程序:nginx] command=bash -c "/usr/sbin/nginx -c /etc/nginx/nginx.conf" stdout_logfile=syslog stderr_logfile=syslog
在 Rails 代码中通过 env var 将 Unicorn 中的日志级别设置为 Warn。
完整的supervisord配置:
[supervisord]
nodaemon=true
loglevel=warn
[program:unicorn]
command=bundle exec unicorn -c /railsapp/config/unicorn.rb
process_name=%(program_name)s_%(process_num)02d
numprocs=1
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
[program:nginx]
command=bash -c "/usr/sbin/nginx -c /etc/nginx/nginx.conf"
stdout_logfile=/dev/null
stderr_logfile=/dev/null
Run Code Online (Sandbox Code Playgroud)
您可以尝试使用以下命令更改 nginx 日志级别:
access_log off;
Run Code Online (Sandbox Code Playgroud)
目标仍然是修改nginx.confnginx 镜像所使用的。
| 归档时间: |
|
| 查看次数: |
3528 次 |
| 最近记录: |