Heroku / Rails错误,日志不是很有帮助

时间:2015-01-27 14:25:17

标签: ruby-on-rails ruby heroku gemfile

我最近开发了我的第一个Ruby on Rails应用程序,并尝试将其部署到Heroku,但是当我尝试加载应用程序URL时,它只返回此页面:

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.

以下是我的日志:

2015-01-27T14:11:44.782093+00:00 heroku[api]: Release v12 created by tom@tomoakley.me
2015-01-27T14:11:45.419564+00:00 heroku[web.1]: State changed from up to starting
2015-01-27T14:11:48.394740+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 21006 -e production`
2015-01-27T14:11:49.304740+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-01-27T14:11:50.179113+00:00 app[web.1]: [2015-01-27 14:11:50] FATAL SignalException: SIGTERM
2015-01-27T14:11:50.179123+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:32:in `start'
2015-01-27T14:11:50.179120+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `select'
2015-01-27T14:11:50.179121+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:170:in `block in start'
2015-01-27T14:11:50.179126+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:35:in `run'
2015-01-27T14:11:50.179124+00:00 app[web.1]:    /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:160:in `start'
2015-01-27T14:11:50.179133+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-01-27T14:11:50.179152+00:00 app[web.1]:    bin/rails:8:in `require'
2015-01-27T14:11:50.179150+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-01-27T14:11:50.179130+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-01-27T14:11:50.179128+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/server.rb:80:in `start'
2015-01-27T14:11:50.179161+00:00 app[web.1]: [2015-01-27 14:11:50] INFO  WEBrick::HTTPServer#start done.
2015-01-27T14:11:50.179127+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/server.rb:286:in `start'
2015-01-27T14:11:50.179160+00:00 app[web.1]: [2015-01-27 14:11:50] INFO  going to shutdown ...
2015-01-27T14:11:50.179131+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-01-27T14:11:50.179151+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
2015-01-27T14:11:50.179153+00:00 app[web.1]:    bin/rails:8:in `<main>'
2015-01-27T14:11:50.265926+00:00 app[web.1]: => Booting WEBrick
2015-01-27T14:11:50.265932+00:00 app[web.1]: => Rails 4.2.0 application starting in production on http://0.0.0.0:39482
2015-01-27T14:11:50.265936+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-01-27T14:11:50.265934+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-01-27T14:11:50.265937+00:00 app[web.1]: Exiting
2015-01-27T14:11:51.162075+00:00 heroku[web.1]: Process exited with status 143
2015-01-27T14:11:52.030623+00:00 app[web.1]: [2015-01-27 14:11:52] INFO  ruby 2.0.0 (2014-11-13) [x86_64-linux]
2015-01-27T14:11:52.030600+00:00 app[web.1]: [2015-01-27 14:11:52] INFO  WEBrick 1.3.1
2015-01-27T14:11:52.030938+00:00 app[web.1]: [2015-01-27 14:11:52] INFO  WEBrick::HTTPServer#start: pid=3 port=21006
2015-01-27T14:11:52.681188+00:00 heroku[web.1]: State changed from starting to up
2015-01-27T14:12:57.646409+00:00 heroku[router]: at=info method=GET path="/" host=www.biblequot.es request_id=8125c7b1-2590-4162-b98f-0b849febe74e fwd="94.175.136.230" dyno=web.1 connect=3ms service=1175ms status=500 bytes=1754

我以前试图弄清楚如何让config/secrets.yml中的密钥不在Github上(回购将公开)并尝试安装GPG并使用dotgpg(使用指南here),但我无法正常工作,所以把它从我的Gemfile中取出,我在下面复制了它:

source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use font-awesome!
gem 'font-awesome-sass'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

另外还有一个很好的衡量标准,这是我的config/enviroment/production.rb文件:

Rails.application.configure do


 # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like
  # NGINX, varnish or squid.
  # config.action_dispatch.rack_cache = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

  # Specifies the header that your server uses for sending files.
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  config.log_level = :debug

  # Prepend all log lines with the following tags.
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups.
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = 'http://assets.example.com'

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation cannot be found).
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false

end

很抱歉在这里放了这么多东西,我只希望有人可以快速解决我的问题:)另外作为奖励,什么是隐藏秘密密钥的最佳方法在secrets.yml?是否有开发和测试密钥是否重要? (生产密钥隐藏在环境变量中)。谢谢!

2 个答案:

答案 0 :(得分:0)

在您的日志中,看起来您的应用程序收到了Sigterm,但是当您看到rails错误消息时 “我们很抱歉,但有些不对劲。”这意味着服务器已启动,错误发生在rails应用程序中。

因此,我们需要查看更多日志来帮助您。

environement变量的最简单方法是使用environement变量的示例创建一个.env.sample,每个开发人员创建自己的.env文件,并在gem 'dotenv-rails', groups: [:development, :test] <内使用带有Gemfile的dotenv-rails / p>

您甚至可以用以下内容替换database.yml:

DATABASE_URL=postgres://username:password@localhost:5432/database_name

但是dotgpg看起来很棒,我会尝试使用它。

答案 1 :(得分:0)

在项目目录中,运行

heroku run console

它应该为您提供更多信息