【问题标题】:Deploy Ruby on Rails to Elastic Bean-Stalk route errors将 Ruby on Rails 部署到 Elastic Bean-Stalk 路由错误
【发布时间】:2016-04-09 20:54:52
【问题描述】:

我刚刚在 Elastic Bean-Stalk (AWS) 上部署了一个 Ruby on Rails 应用程序。当我尝试访问应用程序的 URL 时,我在日志文件中得到以下行。这个问题的原因可能是什么?是来自宝石清单吗?生产需要什么宝石?!

-------------------------------------
/var/app/support/logs/production.log
-------------------------------------
...
I, [2016-01-05T21:12:14.107404 #22655]  INFO -- : Started HEAD "/" for 127.0.0.1 at 2016-01-05 21:12:14 +0000
F, [2016-01-05T21:12:14.179737 #22655] FATAL -- : 
ActionController::RoutingError (No route matches [HEAD] "/"):
  actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  railties (4.2.4) lib/rails/engine.rb:518:in `call'
  railties (4.2.4) lib/rails/application.rb:165:in `call'
  passenger (4.0.59) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
  passenger (4.0.59) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
  passenger (4.0.59) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
  passenger (4.0.59) lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'

【问题讨论】:

  • 在 routes.rb 检查 root 'controller#index'
  • 假设你已经配置了 routes.rb,你的 rails 版本是多少?
  • 确保你的路由支持 HEAD 请求 /

标签: ruby-on-rails amazon-web-services routing amazon-elastic-beanstalk


【解决方案1】:

ElasticBeanstalk 现在通过向根路径发出 HEAD 请求来检查应用程序的运行状况。此 HEAD 请求的响应状态必须为 200,您的应用才会被视为处于正常(绿色)运行状况。 Here's a link with more info.

为了解决这个问题,在 routes.rb 中,将根连接到将返回任何响应的控制器方法。

例如:

class HealthController < ApplicationController #health_controller.rb
  def index
    render json: {status: 'success'}
  end
end


# routes.rb
Rails.application.routes.draw do
  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'health#index'
  ...
end

【讨论】:

    猜你喜欢
    • 2018-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多