2017-01-16 43 views
0

我試圖將我的應用程序從Cloud 9移動到Localhost。這是我迄今爲止所做的:Rails 5:在有流浪者的本地主機上啓動應用程序時超時

  1. 安裝了Vagrant 1.9.1和Virtualbox 5.1.12。在我的Windows 10 64位
  2. 與流浪安裝了Ubuntu 16.04.1和PostgreSQL 9.5
  3. 從我的架構

在終端建立DB rails db:setup我可以啓動Rails的服務器rails server -b 0.0.0.0和它是否正確啓動:

=> Booting Puma 
=> Rails 5.0.1 application starting in development on http://0.0.0.0:3000 
=> Run `rails server -h` for more startup options 
Puma starting in single mode... 
* Version 3.6.2 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity 
* Min threads: 0, max threads: 16 
* Environment: development 
* Listening on tcp://0.0.0.0:3000 
Use Ctrl-C to stop 

當我打開http://localhost:3000/它給了我超時錯誤 Rack::Timeout::RequestTimeoutException in LandingController#index

,並指向我landing/index.html.erb一行:

<img src="<%= image_path('landing/laptop.png') %>" alt="laptop"/>

在終端我看到這條消息:

Rack::Timeout::RequestTimeoutException (Request ran for longer than 20000ms): 

app/views/landing/index.html.erb:51:in `_app_views_landing_index_html_erb___1903502845453706848_40657680' 
app/controllers/landing_controller.rb:6:in `index' 
    Rendering /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout 
    Rendering /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb 
    Rendered /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (11.6ms) 
    Rendering /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb 
    Rendered /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.2ms) 
    Rendering /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb 
    Rendered /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms) 
    Rendered /home/ubuntu/.rvm/gems/ruby-2.3.3/gems/actionpack-5.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (46.7ms) 
source=rack-timeout id=989422929f6047c15c931fac986f4ae0 timeout=20000ms service=22077ms state=completed 

資產到位之前在雲9 - 我確實沒有變化任何東西。 我認爲這是與鏈輪的東西,所以我重新安裝,但沒有運氣 - 錯誤保持。

請問我該如何解決這個問題?謝謝!

更新

沒有什麼特別的控制器:

class LandingController < ApplicationController 
    skip_before_action :logged_in_user, only: [:index] 
    skip_before_action :get_role, only: [:index] 

    def index 
    render layout: 'empty' 
    end 
end 

更新2

誤差保持甚至當我將我的應用程序來RailsInstaller適用於Windows,所以我想流氓不是在我的情況下的責任。任何想法我做錯了什麼?在我看來,有一些相關的東西是我從緩存的Cloud 9複製粘貼的應用程序。

+0

您是否嘗試過刷新幾次?我看到的一件事是,Rack :: Timeout可能會在資產第一次編譯時產生錯誤。我們只是在開發模式下禁用它。 – lobati

+0

刷新沒有幫助。我把'config.assets。enabled = false「在config \ environments \ develoment.rb中,但它也沒有幫助。 – matiss

+0

@lobati看來錯誤與Vagrant無關,因爲當我從沒有VM的RailsInstaller啓動我的應用程序時會出現同樣的錯誤。它可能是與緩存相關的東西嗎? – matiss

回答

2

不知道爲什麼它不是在你的情況下工作的鏈接,但我們發現Rack::Timeout引起足夠的發展頭痛,我們只是將其禁用。您可以通過在開發模式下將超時設置爲0來完成此操作。只需添加一個config/initializers/rack_timeout.rb文件以下內容:

Rack::Timeout.service_timeout = Rails.env.development? ? 0 : 25 
0

會改變<img src="<%= image_path('landing/laptop.png') %>" alt="laptop"/>

<%= image_tag('landing/laptop.png') %>工作?

這裏是到docs

+0

謝謝,但是這不起作用,因爲錯誤仍然存​​在。我相信它與應用程序代碼無關,因爲它在Cloud 9中工作得很好。 – matiss

+0

您是否可以發佈您的landing_controller.rb以及 – disc0ninja

+0

在上面的更新中添加了控制器。 – matiss

相關問題