【问题标题】:500 internal server error when I try to push my app onto Heroku当我尝试将我的应用程序推送到 Heroku 时出现 500 内部服务器错误
【发布时间】:2012-04-06 17:05:49
【问题描述】:

我在将我的应用推送到 Heroku 时遇到了这个问题:

  • 500 内部服务器错误
  • ActionView::Template::Error...application.css 未预编译(请参阅随附的 Heroku 日志)
  • 另外,ActionController::RoutingError(没有路由匹配 [GET] "/assets/rails.png"

我正在使用 Twitter Bootstrap 2.0.1 和 Rails 3.1.1(请参阅下面的 Gemfile)

任何指导将不胜感激!


HEROKU 日志

2012-04-06T16:49:38+00:00 app[web.1]: 
2012-04-06T16:49:38+00:00 app[web.1]: Started GET "/" for 115.186.162.46 at 2012-04-06 09:49:38 -0700
2012-04-06T16:49:38+00:00 app[web.1]:   Processing by PostsController#new as HTML
2012-04-06T16:49:38+00:00 app[web.1]: Rendered posts/_form.html.erb (1.4ms)
2012-04-06T16:49:38+00:00 app[web.1]: Rendered posts/new.html.erb within layouts/application (1.8ms)
2012-04-06T16:49:38+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-04-06T16:49:38+00:00 app[web.1]: 
2012-04-06T16:49:38+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-06T16:49:38+00:00 app[web.1]:     6:     <title>Weddoo!</title>
2012-04-06T16:49:38+00:00 app[web.1]:     7:     <%= csrf_meta_tags %>
2012-04-06T16:49:38+00:00 app[web.1]:     8: 
2012-04-06T16:49:38+00:00 app[web.1]:     9:     <%= stylesheet_link_tag "application", :media => "all" %>
2012-04-06T16:49:38+00:00 app[web.1]:     10: 
2012-04-06T16:49:38+00:00 app[web.1]:     11:     <link href="images/favicon.ico" rel="shortcut icon">
2012-04-06T16:49:38+00:00 app[web.1]:     12:     <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
2012-04-06T16:49:38+00:00 app[web.1]:   app/views/layouts/application.html.erb:9:in `_app_views_layouts_application_html_erb__819333137240276330_18641900'
2012-04-06T16:49:38+00:00 app[web.1]:   app/controllers/posts_controller.rb:24:in `new'
2012-04-06T16:49:38+00:00 app[web.1]: 
2012-04-06T16:49:38+00:00 app[web.1]: 
2012-04-06T16:49:38+00:00 app[web.1]: cache: [GET /] miss
2012-04-06T16:49:38+00:00 heroku[router]: GET weddoo.heroku.com/ dyno=web.1 queue=0 wait=0ms service=11ms status=500 bytes=728
2012-04-06T16:49:38+00:00 heroku[nginx]: 115.186.162.46 - - [06/Apr/2012:16:49:38 +0000] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7" weddoo.heroku.com
2012-04-06T16:49:39+00:00 app[web.1]: 
2012-04-06T16:49:39+00:00 app[web.1]: 
2012-04-06T16:49:39+00:00 app[web.1]: Started GET "/" for 115.186.162.46 at 2012-04-06 09:49:39 -0700
2012-04-06T16:49:39+00:00 app[web.1]:   Processing by PostsController#new as HTML
2012-04-06T16:49:39+00:00 app[web.1]: Rendered posts/new.html.erb within layouts/application (1.6ms)
2012-04-06T16:49:39+00:00 app[web.1]: Rendered posts/_form.html.erb (1.4ms)
2012-04-06T16:49:39+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-04-06T16:49:39+00:00 app[web.1]: 
2012-04-06T16:49:39+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-06T16:49:39+00:00 app[web.1]:     6:     <title>Weddoo!</title>
2012-04-06T16:49:39+00:00 app[web.1]:     9:     <%= stylesheet_link_tag "application", :media => "all" %>
2012-04-06T16:49:39+00:00 app[web.1]:     10: 
2012-04-06T16:49:39+00:00 app[web.1]:     11:     <link href="images/favicon.ico" rel="shortcut icon">
2012-04-06T16:49:39+00:00 app[web.1]:     7:     <%= csrf_meta_tags %>
2012-04-06T16:49:39+00:00 app[web.1]:     8: 
2012-04-06T16:49:39+00:00 app[web.1]:     12:     <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
2012-04-06T16:49:39+00:00 app[web.1]:   app/views/layouts/application.html.erb:9:in `_app_views_layouts_application_html_erb__819333137240276330_18641900'
2012-04-06T16:49:39+00:00 app[web.1]:   app/controllers/posts_controller.rb:24:in `new'
2012-04-06T16:49:39+00:00 app[web.1]: 
2012-04-06T16:49:39+00:00 app[web.1]: 
2012-04-06T16:49:39+00:00 app[web.1]: cache: [GET /] miss
2012-04-06T16:49:39+00:00 heroku[router]: GET weddoo.heroku.com/ dyno=web.1 queue=0 wait=0ms service=10ms status=500 bytes=728
2012-04-06T16:49:39+00:00 heroku[nginx]: 115.186.162.46 - - [06/Apr/2012:16:49:39 +0000] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7" weddoo.heroku.com
2012-04-06T16:51:32+00:00 heroku[slugc]: Slug compilation started
2012-04-06T16:51:46+00:00 heroku[api]: Release v8 created by postkhalid@yahoo.com
2012-04-06T16:51:46+00:00 heroku[api]: Deploy db6820d by postkhalid@yahoo.com
2012-04-06T16:51:46+00:00 heroku[web.1]: State changed from up to bouncing
2012-04-06T16:51:46+00:00 heroku[web.1]: State changed from bouncing to created
2012-04-06T16:51:46+00:00 heroku[web.1]: State changed from created to starting
2012-04-06T16:51:47+00:00 heroku[slugc]: Slug compilation finished
2012-04-06T16:51:48+00:00 heroku[web.1]: Stopping process with SIGTERM
2012-04-06T16:51:48+00:00 app[web.1]: >> Stopping ...
2012-04-06T16:51:50+00:00 heroku[web.1]: Process exited with status 0
2012-04-06T16:51:51+00:00 heroku[web.1]: Starting process with command `thin -p 30481 -e production -R /home/heroku_rack/heroku.ru start`
2012-04-06T16:51:55+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2012-04-06T16:51:55+00:00 app[web.1]: >> Maximum connections set to 1024
2012-04-06T16:51:55+00:00 app[web.1]: >> Listening on 0.0.0.0:30481, CTRL+C to stop
2012-04-06T16:51:56+00:00 heroku[web.1]: State changed from starting to up
2012-04-06T16:51:56+00:00 heroku[rake.1]: State changed from created to starting
2012-04-06T16:52:02+00:00 app[rake.1]: Awaiting client
2012-04-06T16:52:02+00:00 heroku[rake.1]: State changed from starting to up
2012-04-06T16:52:02+00:00 app[rake.1]: Starting process with command `bundle exec rake db:migrate`
2012-04-06T16:52:07+00:00 heroku[rake.1]: Process exited with status 0
2012-04-06T16:52:07+00:00 heroku[rake.1]: State changed from up to complete
2012-04-06T16:52:20+00:00 app[web.1]: 
2012-04-06T16:52:20+00:00 app[web.1]: 
2012-04-06T16:52:20+00:00 app[web.1]: Started GET "/assets/rails.png" for 115.186.162.46 at 2012-04-06 09:52:20 -0700
2012-04-06T16:52:20+00:00 heroku[router]: GET weddoo.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=80ms status=404 bytes=728
2012-04-06T16:52:20+00:00 app[web.1]: 
2012-04-06T16:52:20+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
2012-04-06T16:52:20+00:00 app[web.1]:   
2012-04-06T16:52:20+00:00 app[web.1]: 
2012-04-06T16:52:20+00:00 app[web.1]: 
2012-04-06T16:52:20+00:00 app[web.1]: cache: [GET /assets/rails.png] miss
2012-04-06T16:52:21+00:00 heroku[nginx]: 115.186.162.46 - - [06/Apr/2012:16:52:21 +0000] "GET /assets/rails.png HTTP/1.1" 404 728 "http://weddoo.heroku.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7" weddoo.heroku.com
2012-04-06T16:52:23+00:00 app[web.1]: 
2012-04-06T16:52:23+00:00 app[web.1]: 
2012-04-06T16:52:23+00:00 app[web.1]: Started GET "/" for 115.186.162.46 at 2012-04-06 09:52:23 -0700
2012-04-06T16:52:23+00:00 app[web.1]:   Processing by PostsController#new as HTML
2012-04-06T16:52:23+00:00 app[web.1]: Rendered posts/_form.html.erb (25.6ms)
2012-04-06T16:52:23+00:00 app[web.1]: Rendered posts/new.html.erb within layouts/application (53.8ms)
2012-04-06T16:52:23+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled):
2012-04-06T16:52:23+00:00 app[web.1]: Completed 500 Internal Server Error in 150ms
2012-04-06T16:52:23+00:00 app[web.1]:     6:     <title>Weddoo!</title>
2012-04-06T16:52:23+00:00 app[web.1]: 
2012-04-06T16:52:23+00:00 app[web.1]:     7:     <%= csrf_meta_tags %>
2012-04-06T16:52:23+00:00 app[web.1]:     8: 
2012-04-06T16:52:23+00:00 app[web.1]:     10: 
2012-04-06T16:52:23+00:00 app[web.1]:     9:     <%= stylesheet_link_tag "application", :media => "all" %>
2012-04-06T16:52:23+00:00 app[web.1]:     11:     <link href="images/favicon.ico" rel="shortcut icon">
2012-04-06T16:52:23+00:00 heroku[router]: GET weddoo.heroku.com/ dyno=web.1 queue=0 wait=0ms service=206ms status=500 bytes=728
2012-04-06T16:52:23+00:00 app[web.1]:     12:     <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
2012-04-06T16:52:23+00:00 app[web.1]:   app/views/layouts/application.html.erb:9:in `_app_views_layouts_application_html_erb___37461260917978840_28780360'
2012-04-06T16:52:23+00:00 app[web.1]:   app/controllers/posts_controller.rb:24:in `new'
2012-04-06T16:52:23+00:00 app[web.1]: 
2012-04-06T16:52:23+00:00 app[web.1]: 
2012-04-06T16:52:23+00:00 app[web.1]: cache: [GET /] miss
2012-04-06T16:52:24+00:00 heroku[nginx]: 115.186.162.46 - - [06/Apr/2012:16:52:24 +0000] "GET / HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7" weddoo.heroku.com

GEMFILE

source 'http://rubygems.org'

gem 'rails', '3.1.1'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'pg'
gem 'json'
gem "twitter-bootstrap-rails", "~> 2.0.1.0"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails',   '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

RAKEFILE

#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Mysalary::Application.load_tasks

HEROKU 信息

=== weddoo
Addons:        Shared Database 5MB
Database Size: 64k
Dynos:         1
Git URL:       git@heroku.com:weddoo.git
Owner:         postkhalid@yahoo.com
Repo Size:     11M
Slug Size:     11M
Stack:         bamboo-mri-1.9.2
Web URL:       http://weddoo.heroku.com/
Workers:       0

【问题讨论】:

  • 我不确定这是否更适合网站管理员或服务器故障,但它似乎与编程无关,所以我认为这不是正确的地方。跨度>

标签: ruby-on-rails-3 heroku twitter-bootstrap internal-server-error


【解决方案1】:

因此,根据您提供的heroku info,我看到您在竹堆栈上,并且该堆栈不支持 Rails 3.1+。只有 cedar 堆栈支持 Rails 3.1+。您需要使用以下命令在 cedar 堆栈上创建一个新应用:

heroku create --stack cedar

【讨论】:

    【解决方案2】:

    这是您的样式表没有被编译的结果。 Heroku 将尝试运行

    rake assets:precompile
    

    在部署您的应用之前。如果预编译命令失败,它现在会静默失败。我实际上在 Heroku 上有一个未解决的问题

    https://github.com/heroku/heroku-buildpack-ruby/issues/9

    最可能的原因是 Rakefile 正在尝试加载(或访问)gem。 Heroku buildpacks 尝试在访问 gemset 之前编译样式表,因此任何要求都会失败。避免这种情况的最佳方法是将这些要求包装在您的 Rakefile 中特定于环境的条件中:

    if Rails.env == 'development' || Rails.env == 'test'
      require 'somegem1'
      require 'somegem2'
    
      # whatever code is being used by those gems goes in this block
    end
    

    【讨论】:

    • 我很困惑...你能详细说明一下吗?我在哪里可以找到 rake 文件?还有我用什么代替'somegem1,2'和'#whatever code..'?谢谢...
    • Rakefile 位于您应用的根目录中。如果您能说出内容,我应该可以告诉您这是否是问题
    • 谢谢@bcardarella !!我在上面添加了 rake 文件的内容......让我知道你的想法。
    • 你能在你的应用上运行“heroku info”并粘贴上面的结果吗?
    猜你喜欢
    • 1970-01-01
    • 2014-10-09
    • 2015-05-04
    • 2014-07-08
    • 2016-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多