Nginx和Unicorn进行Rails部署会导致504网关超时错误 [英] Rails Deployment with Nginx and Unicorn giving 504 gateway timeout error

查看:131
本文介绍了Nginx和Unicorn进行Rails部署会导致504网关超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Nginx服务器无法在VPS上正常运行 我正确地进行了所有设置,根据rails cast VPS Deployment

My Nginx server is not running properly on VPS i did all the settings correctly, According to rails cast VPS Deployment

我仍然收到错误504网关超时错误

still I am getting the error 504 Gateway timeout error

Nginx日志

    request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"
2014/07/26 11:33:58 [error] 6935#0: *10 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 223.239.147.104, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"
2014/07/26 11:45:56 [error] 6935#0: *20 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 223.239.147.104, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"
2014/07/26 11:48:46 [error] 6935#0: *24 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 223.239.147.104, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"
2014/07/26 11:50:03 [error] 6935#0: *24 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 223.239.147.104, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"
2014/07/26 11:51:06 [error] 6935#0: *24 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 223.239.147.104, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "roomies.co.in"

Nginx日志上方

下面是独角兽原木

/home/rails/releases/20140726114415/config/boot.rb:4:in `<top (required)>'
/usr/loc
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `block in builder'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `call'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `build_app!'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:623:in `init_worker_process'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:643:in `worker_loop'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:527:in `spawn_missing_workers'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:538:in `maintain_worker_count'
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:303:in `join'
/usr/local/rvm/gems/ruby-2`enter code here`.0.0-p353/gems/unicorn-4.7.0/bin/unicorn:126:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `<main>'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
E, [2014-07-26T11:59:07.161500 #24415] ERROR -- : reaped #<Process::Status: pid 29887 exit 1> worker=0
I, [2014-07-26T11:59:07.161888 #24415]  INFO -- : worker=0 spawning...
E, [2014-07-26T11:59:07.162737 #24415] ERROR -- : reaped #<Process::Status: pid 29885 exit 1> worker=1
I, [2014-07-26T11:59:07.163084 #24415]  INFO -- : worker=1 spawning...
I, [2014-07-26T11:59:07.164414 #29891]  INFO -- : worker=0 spawned pid=29891
I, [2014-07-26T11:59:07.167923 #29893]  INFO -- : worker=1 spawned pid=29893
I, [2014-07-26T11:59:07.186676 #29891]  INFO -- : Refreshing Gem list
I, [2014-07-26T11:59:07.188107 #29893]  INFO -- : Refreshing Gem list

Unicorn.rb文件

Unicorn.rb file

listen "127.0.0.1:8080"
worker_processes 2
user "rails"
worker_processes 2
timeout 30
working_directory "/home/rails/current"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"

如果有人熟悉这种问题,请提供帮助

Please help if anybody is familiar with these kind of problem

Error I am getting after running bundle exec unicorn_rails

E, [2014-07-26T13:27:52.445453 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
E, [2014-07-26T13:27:52.451129 #16467] ERROR -- : retrying in 0.5 seconds (4 tries left)
E, [2014-07-26T13:27:52.951675 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
E, [2014-07-26T13:27:52.951799 #16467] ERROR -- : retrying in 0.5 seconds (3 tries left)
E, [2014-07-26T13:27:53.452214 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
E, [2014-07-26T13:27:53.452339 #16467] ERROR -- : retrying in 0.5 seconds (2 tries left)
E, [2014-07-26T13:27:53.952728 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
E, [2014-07-26T13:27:53.952846 #16467] ERROR -- : retrying in 0.5 seconds (1 tries left)
E, [2014-07-26T13:27:54.453490 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
E, [2014-07-26T13:27:54.453733 #16467] ERROR -- : retrying in 0.5 seconds (0 tries left)
E, [2014-07-26T13:27:54.954208 #16467] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/socket_helper.rb:185:in `bind': Address already in use - bind(2) (Errno::EADDRINUSE)
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/socket_helper.rb:185:in `new_tcp_server'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/socket_helper.rb:165:in `bind_listen'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:242:in `listen'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:809:in `block in bind_new_listeners!'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:809:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:809:in `bind_new_listeners!'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:138:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/unicorn-4.8.3/bin/unicorn_rails:209:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/unicorn_rails:23:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/unicorn_rails:23:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/r

推荐答案

好像您的独角兽工人正在被系统或诸如Monit之类的外部监视工具杀死.

Seems like your Unicorn workers are being killed by system or some outside monitoring tool like Monit.

我的想法是:

1-您的VPS资源(内存)不足,无法生成2个独角兽工作者.

1 - Either your VPS resources (memory) are low for spawning 2 unicorn workers.

2-否则,由于资源消耗,监视工具会杀死您的独角兽进程.

2 - Or a monitoring tool kills your unicorn processes because of the resource consumption.

您可以检查这些类似的问题.

You can check these similar problems.

Unicorn错误:"ERROR-: #< Process :: Status:pid 12345 SIGABRT(signal 6)> worker = 2"

错误-:已获得#< Process ::状态:pid 4335退出1> worker = 0

这篇关于Nginx和Unicorn进行Rails部署会导致504网关超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆