2013-09-23 28 views
11

Đột nhiên khi tôi chạy ứng dụng cục bộ, tôi nhận được đầu ra bàn điều khiển kép. Có ai biết những gì có thể đã gây ra điều này? Vấn đề tồn tại cả khi chạy Thin và UnicornĐầu ra bàn điều khiển kép?

=> Booting Thin 
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000 
=> Run `rails server -h` for more startup options 
=> Ctrl-C to shutdown server 
>> Thin web server (v1.5.1 codename Straight Razor) 
>> Maximum connections set to 1024 
>> Listening on 0.0.0.0:3000, CTRL+C to stop 
Started GET "/" for 127.0.0.1 at 2013-09-05 22:21:21 +0200 
Started GET "/" for 127.0.0.1 at 2013-09-05 22:21:21 +0200 
Processing by HomeController#index as HTML 
Processing by HomeController#index as HTML 
    Rendered home/index.html.erb within layouts/application (299.5ms) 
    Rendered home/index.html.erb within layouts/application (299.5ms) 
    Rendered layouts/_navbar.html.erb (38.3ms) 
    Rendered layouts/_navbar.html.erb (38.3ms) 
    Rendered layouts/_footer.html.erb (0.8ms) 
    Rendered layouts/_footer.html.erb (0.8ms) 
Completed 200 OK in 704ms (Views: 428.1ms | ActiveRecord: 52.4ms) 
Completed 200 OK in 704ms (Views: 428.1ms | ActiveRecord: 52.4ms) 

Đây là Gemfile tôi

# Gemfile 
source 'https://rubygems.org' 

ruby '2.0.0' 

gem 'rails' 

gem 'actionpack-action_caching' 
gem 'asset_sync' 
gem 'authlogic', github: 'binarylogic/authlogic' 
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3' 
gem 'coffee-rails' 
gem 'dalli' 
gem 'font-awesome-rails' 
gem 'highcharts-rails' 
gem 'jbuilder' 
gem 'jquery-rails' 
gem 'memcachier' 
gem 'newrelic_rpm' 
gem 'pg' 
gem 'prawn', '>= 1.0.0.rc2' 
gem 'prawn_rails' 
gem 'rack-mini-profiler', require: 'rack-mini-profiler' 
gem 'rack-timeout' 
gem 'rails-i18n' 
gem 'rails_12factor' # required by Heroku 
gem 'sass-rails' 
gem 'uglifier' 
gem 'yui-compressor' 

group :production do 
    gem 'justonedb' 
    gem 'unicorn-rails' 
end 

group :development do 
    gem 'annotate' 
    gem 'better_errors' 
    gem 'binding_of_caller' 
    gem 'hirb' 
    gem 'lol_dba' # To find table in need of indexes run 'lol_dba db:find_indexes' 
    gem 'mailcatcher' 
    gem 'pry' 
    gem 'quiet_assets' 
end 

group :test do 
    gem 'capybara' 
    gem 'capybara-webkit' 
    gem 'factory_girl_rails', require: false 
    gem 'fuubar' 
    gem 'rspec-rails' 
    gem 'rails_12factor' 
end 

development.rb My

# development.rb 
Beerclub::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb. 
    config.log_level = :debug 

    # In the development environment your application's code is reloaded on 
    # every request. This slows down response time but is perfect for development 
    # since you don't have to restart the web server when you make code changes. 
    config.cache_classes = false 

    # Do not eager load code on boot. 
    config.eager_load = false 

    # Show full error reports and disable caching. 
    config.consider_all_requests_local  = true 
    config.action_controller.perform_caching = false 

    # Don't care if the mailer can't send. 
    config.action_mailer.raise_delivery_errors = false 

    # Print deprecation notices to the Rails logger. 
    config.active_support.deprecation = :log 

    # Raise an error on page load if there are pending migrations 
    config.active_record.migration_error = :page_load 

    # Debug mode disables concatenation and preprocessing of assets. 
    # This option may cause significant delays in view rendering with a large 
    # number of complex assets. 
    config.assets.compress = false 
    config.assets.debug = true 
    config.serve_static_assets = true 
end 

và application.rb

require File.expand_path('../boot', __FILE__) 

require 'rails/all' 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(:default, Rails.env) 

module Beerclub 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    config.time_zone = 'Copenhagen' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 
    config.i18n.default_locale = :da 

    # Enable the asset pipeline 
    config.assets.enabled = true 
    config.assets.version = '1.0' 

    # Needs to be false on Heroku 
    config.serve_static_assets = false 
    config.static_cache_control = "public, max-age=31536000" 

    # Add the fonts path 
    config.assets.paths << Rails.root.join('app', 'assets', 'fonts') 
    config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts') 

    # Precompile additional assets 
    config.assets.precompile += %w(*.svg *.eot *.woff *.ttf) 
    config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) 
    end 
end 
+0

Hãy xem đá quý của bạn đảm bảo rằng bạn không có bản sao trong đó – MZaragoza

+0

@MoisesZaragoza Bundler thường cảnh báo khi bạn có đá quý trùng lặp. –

Trả lời

1

Kiểm tra nếu bạn có mã như thế này trong ứng dụng:

<img src="#"> 

Đường ray đôi khi tạo bản ghi trùng lặp vì điều này.

Bạn có thể thử thực hiện:

rake assets:clean 

Hoặc có thể, cho ý kiến ​​ra dòng này trong development.rb, có thể làm việc:

config.active_support.deprecation = :log 

Là một cố gắng cuối, thậm chí bạn có thể thử thay đổi thư mục của ứng dụng và sau đó bắt đầu máy chủ để xem kết quả.

Chúc mừng!

+1

Hãy dành thời gian để sử dụng đúng ngữ pháp trong câu trả lời của bạn. Không sử dụng "u" khi bạn muốn nói "bạn". Danh từ thích hợp, như "đường ray" được viết hoa. Cảm ơn. –

+1

chắc chắn, sẽ giữ ThaT Trong minD – aelor

+0

Tôi không chắc chắn nhận xét "config.active_support.deprecation =: log" là một ý tưởng hay, cũng không giải quyết được vấn đề. Nhận xét cho biết "Thông báo phản đối #Print cho trình ghi nhật ký Rails". –

11

Tôi nhận thấy điều này xảy ra do đá quý rails_12factor. Nếu bạn nhận xét ra gem rails_12factor từ Gemfile đầu ra kép của bạn sẽ biến mất. Tôi đoán là đầu ra kép không quan trọng vì bạn cần đá quý cho Heroku. Đối với lý do tại sao đá quý rails_12factor gây ra điều này tôi không có ý tưởng.

12

liên quan đến rails_12factor - nếu bạn thay đổi dòng trong Gemfile tới:

gem 'rails_12factor', group: :production 

bạn sẽ không còn thấy sản lượng tăng gấp đôi trong giao diện điều khiển trong khi gỡ lỗi vv

+0

http://static.tvtropes.org/pmwiki/pub/images/MTG-ThreadNecromancer_3198.jpg – Esse

+0

Đã khắc phục sự cố của tôi, cảm ơn bạn đã dành thời gian trả lời. – Asciant

0

Từ ví dụ của bạn, nó cho thấy rằng các bản sao đang diễn ra nội dòng, tức là.

A 
A 
B 
B 
C 
C 

Nếu thay vào đó bạn đang nhìn thấy những gì dường như là hai back-to-back yêu cầu trùng lặp, ví dụ:

A 
B 
C 

A 
B 
C 

Bạn nên cân nhắc mạnh @ câu trả lời aelor của săn bắn xuống một <img src="#"> hoặc tự tương tự thẻ url tương ứng. Tôi đã mất nhiều giờ cố gắng tìm ra lý do tại sao ứng dụng của tôi đã xuất hiện để thực hiện hai yêu cầu trùng lặp, và sau khi trả lời đọc @ aelor của tôi thấy

%link{href: "", rel: "shortcut icon"}/ 

trong mã của tôi! Nó đã gây ra mọi trang của ứng dụng sản xuất của tôi được dựng hình đôi !!!! Vì vậy, xấu cho hiệu suất và rất khó chịu!

0

Do Rails 4.2 và thời điểm đăng bài này, giải pháp duy nhất tôi biết là xóa rails_12factor khỏi Gemfile.

Thêm group: :production không còn ngăn việc ghi nhật ký kép nữa. Có một vấn đề mở với Heroku trên github:

https://github.com/heroku/rails_stdout_logging/issues/1

0

Chúng tôi thấy điều này là do chạy máy chủ Rails qua

$ rails server 

hơn

$ thin start 

Khi sử dụng sau này , sự cố đăng nhập đôi sẽ biến mất. Thật không may, chúng tôi không có thời gian để khóa nguyên nhân, chúng tôi chỉ thay đổi cách chúng tôi đưa ra Thin và tiếp tục.