我试图在AWS盒子上设置一个Unicorn,但是工作人员只是暂时停止,我不知道为什么。
我正在使用Ubuntu Server 14.04 LTS AMI,安装标准Ruby on Rails安装所需的一切。使用rails new,我生成一个空的应用程序,第一次尝试访问它似乎很快,但之后工作人员只是连续超时并永远服务于网页。加载标准WEBrick服务器没有这个问题,几乎立即加载页面。我试过回滚几个版本的红宝石和独角兽没有运气。在VM中本地不会发生此行为。
以下是在调试模式下运行的服务器的日志
I, [2014-11-04T18:30:13.290599 #17134] INFO -- : listening on addr=0.0.0.0:5000 fd=10 I, [2014-11-04T18:30:13.362993 #17134] INFO -- : master process ready I, [2014-11-04T18:30:13.363098 #17137] INFO -- : worker=0 ready I, [2014-11-04T18:30:13.365175 #17140] INFO -- : worker=1 ready I, [2014-11-04T18:30:13.365314 #17142] INFO -- : worker=2 ready Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:443 - cannot load such file -- rails/application_helper.rb Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:352 - cannot load such file -- rails/application_helper.rb Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:313 - No such file to load -- rails/application_helper Exception 'AbstractController::Helpers::MissingHelperError' at /var/lib/gems/2.1.0/gems/actionpack-4.1.7/lib/abstract_controller/helpers.rb:154 - Missing helper file helpers/rails/application_helper.rb Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:443 - cannot load such file -- rails/welcome_helper.rb Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:352 - cannot load such file -- rails/welcome_helper.rb Exception 'LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:313 - No such file to load -- rails/welcome_helper Exception 'AbstractController::Helpers::MissingHelperError' at /var/lib/gems/2.1.0/gems/actionpack-4.1.7/lib/abstract_controller/helpers.rb:154 - Missing helper file helpers/rails/welcome_helper.rb **** - - [04/Nov/2014 18:30:13] "GET / HTTP/1.1" 200 - 0.0693 **** - - [04/Nov/2014 18:30:14] "GET %2Ffavicon.ico HTTP/1.1" 304 - 0.0441 E, [2014-11-04T18:30:45.395879 #17134] ERROR -- : worker=0 PID:17137 timeout (31s > 30s), killing E, [2014-11-04T18:30:45.395995 #17134] ERROR -- : worker=1 PID:17140 timeout (31s > 30s), killing E, [2014-11-04T18:30:45.396072 #17134] ERROR -- : worker=2 PID:17142 timeout (31s > 30s), killing E, [2014-11-04T18:30:45.397748 #17134] ERROR -- : reaped # worker=2 E, [2014-11-04T18:30:45.397882 #17134] ERROR -- : worker=0 PID:17137 timeout (31s > 30s), killing E, [2014-11-04T18:30:45.397990 #17134] ERROR -- : worker=1 PID:17140 timeout (31s > 30s), killing E, [2014-11-04T18:30:45.401016 #17134] ERROR -- : reaped # worker=1 E, [2014-11-04T18:30:45.401177 #17134] ERROR -- : worker=0 PID:17137 timeout (31s > 30s), killing I, [2014-11-04T18:30:45.402352 #17148] INFO -- : worker=2 ready E, [2014-11-04T18:30:45.403784 #17134] ERROR -- : reaped # worker=0 I, [2014-11-04T18:30:45.405625 #17152] INFO -- : worker=1 ready I, [2014-11-04T18:30:45.406871 #17155] INFO -- : worker=0 ready Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:443 - cannot load such file -- rails/application_helper.rb Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:352 - cannot load such file -- rails/application_helper.rb Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:313 - No such file to load -- rails/application_helper Exception `AbstractController::Helpers::MissingHelperError' at /var/lib/gems/2.1.0/gems/actionpack-4.1.7/lib/abstract_controller/helpers.rb:154 - Missing helper file helpers/rails/application_helper.rb Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:443 - cannot load such file -- rails/welcome_helper.rb Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:352 - cannot load such file -- rails/welcome_helper.rb Exception `LoadError' at /var/lib/gems/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:313 - No such file to load -- rails/welcome_helper Exception `AbstractController::Helpers::MissingHelperError' at /var/lib/gems/2.1.0/gems/actionpack-4.1.7/lib/abstract_controller/helpers.rb:154 - Missing helper file helpers/rails/welcome_helper.rb **** - - [04/Nov/2014 18:31:14] "GET / HTTP/1.1" 200 - 0.0680 Exception 'EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached Exception 'EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached E, [2014-11-04T18:31:45.465765 #17134] ERROR -- : worker=2 PID:17148 timeout (31s > 30s), killing E, [2014-11-04T18:31:45.468770 #17134] ERROR -- : reaped # worker=2 I, [2014-11-04T18:31:45.472177 #17162] INFO -- : worker=2 ready E, [2014-11-04T18:31:49.474506 #17134] ERROR -- : worker=1 PID:17152 timeout (31s > 30s), killing E, [2014-11-04T18:31:49.474633 #17134] ERROR -- : worker=0 PID:17155 timeout (31s > 30s), killing E, [2014-11-04T18:31:49.476313 #17134] ERROR -- : reaped # worker=1 E, [2014-11-04T18:31:49.476451 #17134] ERROR -- : worker=0 PID:17155 timeout (31s > 30s), killing I, [2014-11-04T18:31:49.481324 #17166] INFO -- : worker=1 ready E, [2014-11-04T18:31:49.481548 #17134] ERROR -- : reaped # worker=0 I, [2014-11-04T18:31:49.484368 #17169] INFO -- : worker=0 ready E, [2014-11-04T18:32:17.511012 #17134] ERROR -- : worker=2 PID:17162 timeout (31s > 30s), killing E, [2014-11-04T18:32:17.512733 #17134] ERROR -- : reaped # worker=2 I, [2014-11-04T18:32:17.516074 #17174] INFO -- : worker=2 ready E, [2014-11-04T18:32:21.518316 #17134] ERROR -- : worker=0 PID:17169 timeout (31s > 30s), killing E, [2014-11-04T18:32:21.520011 #17134] ERROR -- : reaped # worker=0 I, [2014-11-04T18:32:21.523230 #17177] INFO -- : worker=0 ready
这是Unicorn配置文件
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) timeout 30 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
我确实注意到了EOF错误,并怀疑这可能与超时有关,但我不确定。
Exception `EOFError' at /var/lib/gems/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_request.rb:79 - end of file reached
答案 0 :(得分:0)
所以问题似乎是我私下运行AWS实例(没有公共IP),然后连接到Load Balancer。删除负载均衡器并直接访问实例可以解决工作人员超时问题,并且不会导致性能下降。