evf*_*qcg 16 ruby-on-rails http nginx
我有一个奇怪的问题,只有当我使用nginx和独角兽时才出现在生产环境中.当我使用没有nginx的独角兽时,它不会发生.
问题.我有一个简单的oauth身份验证,允许用户通过GitHub注册.在GitHub的授权页面上按"允许"后,用户将被重定向到回叫路由.然后,他/她得到302 Bad Gateway
错误.Nginx日志显示我的错误(键被替换为"...")
2012/12/26 18:03:08 [错误] 1467#0:*1上游过早关闭连接,同时从上游读取响应头,客户端:10.0.2.2,服务器:_,请求:"GET/auth/github/callback ?code =&state = ... HTTP/1.1",上游:"http:// unix:/tmp/unicorn.tm.sock:/ auth/github/callback?code = ...&state = ...",主持人:"localhost:3000"
Ther是我的nginx配置.
upstream unicorn {
server unix:/tmp/unicorn.tm.sock fail_timeout=0;
}
server {
listen 80 default deferred;
client_max_body_size 4G;
server_name _;
keepalive_timeout 75s;
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
root /vagrant/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
proxy_buffer_size 16k;
proxy_busy_buffers_size 16k;
}
error_page 500 502 503 504 /500.html;
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是为什么会发生这种情况,是否有任何可能的解决办法?
我已经谷歌搜索了一段时间,但没有运气.
更新
感谢您的评论,我刚刚尝试设置fail_timeout=30s
并确实有所帮助,但是请求大约需要40秒才能完成.但是,无论如何,我会尝试使用这些参数过期.
根据建议,我稍微更新了我的配置,但仍然得到相同的错误.
此外,这是独角兽错误日志.好像它会杀死需要超过30秒的请求,但我想从oauth站点重定向可能不会那么长......
(github) Request phase initiated.
(github) Callback phase initiated.
E, [2012-12-26T19:33:13.058183 #6002] ERROR -- : worker=0 PID:6005 timeout (31s > 30s), killing
E, [2012-12-26T19:33:13.067011 #6002] ERROR -- : reaped #<Process::Status: pid 6005 SIGKILL (signal 9)> worker=0
I, [2012-12-26T19:33:13.067198 #6002] INFO -- : worker=0 spawning...
I, [2012-12-26T19:33:13.068631 #6012] INFO -- : worker=0 spawned pid=6012
I, [2012-12-26T19:33:13.068726 #6012] INFO -- : Refreshing Gem list
I, [2012-12-26T19:33:17.140948 #6012] INFO -- : worker=0 ready
Run Code Online (Sandbox Code Playgroud)
独角兽配置
rails_env = ENV['RAILS_ENV'] || 'production'
worker_processes 1
listen "/tmp/unicorn.tm.sock", :backlog => 64
listen 8080, :tcp_nopush => true
timeout 30
pid "/tmp/unicorn.pid"
stderr_path "/tmp/unicorn.log"
stdout_path "/tmp/unicorn.log"
check_client_connection false
Run Code Online (Sandbox Code Playgroud)
Eug*_*rke 24
ERROR -- : worker=0 PID:6005 timeout (31s > 30s), killing
Run Code Online (Sandbox Code Playgroud)
不言而喻,在unicorn配置中你只需要超过30的安装超时
至少尝试一下
timeout 60
Run Code Online (Sandbox Code Playgroud)
http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-timeout
归档时间: |
|
查看次数: |
13843 次 |
最近记录: |