简体   繁体   English

调试Heroku部署(500错误)

[英]Debugging Heroku Deployment (500 Error)

I've been working on deploying my first rails app to heroku for the past few nights and am struggling to figure out how to solve this problem. 在过去的几个晚上我一直在努力将我的第一个rails应用程序部署到heroku,并且正在努力弄清楚如何解决这个问题。

I used Michael Hartl's tutorial (http://ruby.railstutorial.org/chapters/beginning#sec-deploying) to make sure I set up my app on the Cedar Stack. 我使用Michael Hartl的教程(http://ruby.railstutorial.org/chapters/beginning#sec-deploying)来确保我在Cedar Stack上设置我的应用程序。

Per the Heroku tutorial, I'm using "thin" as the server. 根据Heroku教程,我使用“瘦”作为服务器。

I've read a bunch of posts and have precompiled my assets using: 我已经阅读了很多帖子并使用以下方法预编译了我的资产:

heroku run bundle exec rake assets:precompile bundle exec rake assets:precompile heroku run bundle exec rake assets:precompile bundle exec rake assets:precompile

I have also migrated my databases. 我也迁移了我的数据库。

My app works on my localhost. 我的应用程序适用于我的localhost。

Here is my gemfile: 这是我的gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby'
gem 'thin'

group :development, :test do
  gem 'rspec-rails'
end

group :development do
  gem 'sqlite3'
end

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

group :production do
  gem 'pg'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :test do
  gem 'capybara'
  gem 'factory_girl_rails'
end

Here are my heroku logs 这是我的heroku日志

2012-09-02T01:56:17+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-09-02T01:56:20+00:00 app[web.1]: => Booting Thin
2012-09-02T01:56:20+00:00 app[web.1]: => Rails 3.2.8 application starting in production on http://0.0.0.0:50510
2012-09-02T01:56:20+00:00 app[web.1]: => Call with -d to detach
2012-09-02T01:56:20+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-09-02T01:56:20+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2012-09-02T01:56:21+00:00 app[web.1]: >> Thin web server (v1.4.1 codename Chromeo)
2012-09-02T01:56:21+00:00 app[web.1]: >> Maximum connections set to 1024
2012-09-02T01:56:21+00:00 app[web.1]: >> Listening on 0.0.0.0:50510, CTRL+C to stop
2012-09-02T01:56:21+00:00 heroku[web.1]: State changed from starting to up
2012-09-02T01:56:23+00:00 app[web.1]: 
2012-09-02T01:56:23+00:00 app[web.1]: 
2012-09-02T01:56:23+00:00 app[web.1]: Started GET "/" for 108.210.1.241 at 2012-09-02 01:56:23 +0000
2012-09-02T01:56:23+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2012-09-02T01:56:23+00:00 app[web.1]:   Rendered static_pages/home.html.erb within layouts/application (14.9ms)
2012-09-02T01:56:23+00:00 app[web.1]: Completed 500 Internal Server Error in 103ms
2012-09-02T01:56:23+00:00 app[web.1]: ActionView::Template::Error (screen.css isn't precompiled):
2012-09-02T01:56:23+00:00 app[web.1]: 
2012-09-02T01:56:23+00:00 app[web.1]:     2: <html>
2012-09-02T01:56:23+00:00 app[web.1]:     3: <head>
2012-09-02T01:56:23+00:00 heroku[router]: GET morning-inlet-9513.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=262ms status=500 bytes=643
2012-09-02T01:56:23+00:00 app[web.1]:     4:   <title>GabisBag</title>
2012-09-02T01:56:23+00:00 app[web.1]: 
2012-09-02T01:56:23+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "screen", :media => "screen" %>
2012-09-02T01:56:23+00:00 app[web.1]: 
2012-09-02T01:56:23+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__1090905269972481286_30934000'
2012-09-02T01:56:23+00:00 app[web.1]:     6:   <%= stylesheet_link_tag    "landing_pages", :media => "screen" %>
2012-09-02T01:56:23+00:00 app[web.1]:     7:   <%= javascript_include_tag "application" %>
2012-09-02T01:56:23+00:00 app[web.1]:     8:   <%= csrf_meta_tags %>
2012-09-02T02:05:54+00:00 heroku[api]: Starting process with command `bundle exec rake assets:precompile` by jflores1@alumni.nd.edu
2012-09-02T02:05:57+00:00 heroku[run.1]: Awaiting client
2012-09-02T02:05:57+00:00 heroku[run.1]: Starting process with command `bundle exec rake assets:precompile`
2012-09-02T02:05:58+00:00 heroku[run.1]: State changed from starting to up
2012-09-02T02:06:14+00:00 heroku[run.1]: Client connection closed. Sending SIGHUP to all processes
2012-09-02T02:06:15+00:00 heroku[run.1]: Process exited with status 0
2012-09-02T02:06:15+00:00 heroku[run.1]: State changed from up to complete
2012-09-02T02:08:22+00:00 heroku[slugc]: Slug compilation started
2012-09-02T02:08:37+00:00 heroku[api]: D
eploy 6817a8e by jflores1@alumni.nd.edu
2012-09-02T02:08:37+00:00 heroku[api]: Release v8 created by jflores1@alumni.nd.edu
2012-09-02T02:08:38+00:00 heroku[web.1]: State changed from up to starting
2012-09-02T02:08:38+00:00 heroku[slugc]: Slug compilation finished
2012-09-02T02:08:40+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -p 42652 -e production`
2012-09-02T02:08:41+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2012-09-02T02:08:41+00:00 app[web.1]: Exiting
2012-09-02T02:08:42+00:00 heroku[web.1]: Process exited with status 0
2012-09-02T02:08:44+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-09-02T02:08:44+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-09-02T02:08:47+00:00 app[web.1]: => Booting Thin
2012-09-02T02:08:47+00:00 app[web.1]: => Rails 3.2.8 application starting in production on http://0.0.0.0:42652
2012-09-02T02:08:47+00:00 app[web.1]: => Call with -d to detach
2012-09-02T02:08:47+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-09-02T02:08:47+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2012-09-02T02:08:48+00:00 app[web.1]: >> Thin web server (v1.4.1 codename Chromeo)
2012-09-02T02:08:48+00:00 app[web.1]: >> Maximum connections set to 1024
2012-09-02T02:08:48+00:00 app[web.1]: >> Listening on 0.0.0.0:42652, CTRL+C to stop
2012-09-02T02:08:49+00:00 heroku[web.1]: State changed from starting to up
2012-09-02T02:08:50+00:00 app[web.1]: Started GET "/" for 108.210.1.241 at 2012-09-02 02:08:50 +0000
2012-09-02T02:08:50+00:00 app[web.1]: 
2012-09-02T02:08:50+00:00 app[web.1]: 
2012-09-02T02:08:50+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2012-09-02T02:08:50+00:00 app[web.1]:   Rendered static_pages/home.html.erb within layouts/application (9.3ms)
2012-09-02T02:08:50+00:00 app[web.1]: Completed 500 Internal Server Error in 77ms
2012-09-02T02:08:50+00:00 app[web.1]: 
2012-09-02T02:08:50+00:00 app[web.1]: ActionView::Template::Error (screen.css isn't precompiled):
2012-09-02T02:08:50+00:00 app[web.1]:     2: <html>
2012-09-02T02:08:50+00:00 app[web.1]:     3: <head>
2012-09-02T02:08:50+00:00 app[web.1]:     4:   <title>GabisBag</title>
2012-09-02T02:08:50+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "screen", :media => "screen" %>
2012-09-02T02:08:50+00:00 app[web.1]:     6:   <%= stylesheet_link_tag    "landing_pages", :media => "screen" %>
2012-09-02T02:08:50+00:00 app[web.1]:     7:   <%= javascript_include_tag "application" %>
2012-09-02T02:08:50+00:00 app[web.1]:     8:   <%= csrf_meta_tags %>
2012-09-02T02:08:50+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__3619394764979485472_40067220'
2012-09-02T02:08:50+00:00 app[web.1]: 
2012-09-02T02:08:50+00:00 app[web.1]: 
2012-09-02T02:08:50+00:00 heroku[router]: GET morning-inlet-9513.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=221ms status=500 bytes=643
2012-09-02T02:14:08+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by jflores1@alumni.nd.edu
2012-09-02T02:14:10+00:00 heroku[run.1]: Awaiting client
2012-09-02T02:14:10+00:00 heroku[run.1]: Starting process with command `bundle exec rake db:migrate`
2012-09-02T02:14:11+00:00 heroku[run.1]: State changed from starting to up
2012-09-02T02:14:17+00:00 heroku[run.1]: Client connection closed. Sending SIGHUP to all processes
2012-09-02T02:14:18+00:00 heroku[run.1]: Process exited with status 0
2012-09-02T02:14:18+00:00 heroku[run.1]: State changed from up to complete
2012-09-02T02:14:35+00:00 app[web.1]: 
2012-09-02T02:14:35+00:00 app[web.1]: Started GET "/" for 108.210.1.241 at 2012-09-02 02:14:35 +0000
2012-09-02T02:14:35+00:00 app[web.1]: 
2012-09-02T02:14:35+00:00 app[web.1]: Processing by StaticPagesController#home as HTML
2012-09-02T02:14:35+00:00 app[web.1]:   Rendered static_pages/home.html.erb within layouts/application (0.5ms)
2012-09-02T02:14:35+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms
2012-09-02T02:14:35+00:00 app[web.1]: 
2012-09-02T02:14:35+00:00 app[web.1]: ActionView::Template::Error (screen.css isn't precompiled):
2012-09-02T02:14:35+00:00 app[web.1]:     2: <html>
2012-09-02T02:14:35+00:00 app[web.1]:     3: <head>
2012-09-02T02:14:35+00:00 app[web.1]:     4:   <title>GabisBag</title>
2012-09-02T02:14:35+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "screen", :media => "screen" %>
2012-09-02T02:14:35+00:00 app[web.1]:     6:   <%= stylesheet_link_tag    "landing_pages", :media => "screen" %>
2012-09-02T02:14:35+00:00 app[web.1]:     7:   <%= javascript_include_tag "application" %>
2012-09-02T02:14:35+00:00 app[web.1]:     8:   <%= csrf_meta_tags %>
2012-09-02T02:14:35+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__3619394764979485472_40067220'
2012-09-02T02:14:35+00:00 app[web.1]: 
2012-09-02T02:14:35+00:00 app[web.1]: 
2012-09-02T02:14:35+00:00 heroku[router]: GET morning-inlet-9513.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=11ms status=500 bytes=643

This looks like the important part: 这看起来像是重要的部分:

ActionView::Template::Error (screen.css isn't precompiled):

Seems as though this thread will fix your problem. 似乎这个线程将解决您的问题。

As it says: 正如它所说:

On heroku server (readonly filesystem), If you want runtime compilation of css (its not recommended but you can do it), make sure you have done settings like below -

# inside config/application.rb
config.assets.enabled = true
config.assets.prefix = Rails.root.join('tmp/assets').to_s

# If you are using sass then keep gem outside of asset group
 gem 'sass-rails',   '3.1.4'

# inside config/environments/production.rb
config.assets.compile = true

I found the answer here: blueprint css rails 3.1 help 我在这里找到了答案: 蓝图css rails 3.1帮助

So far as I can tell, this appears to be a problem with using the Blueprint CSS Framework. 据我所知,这似乎是使用Blueprint CSS Framework的一个问题。 That said, two other notes: 那说,另外两个说明:

  1. I commented out the <%= stylesheet_link_tag "screen", :media=>"screen"%> code from my application.html.erb layout file. 我从application.html.erb布局文件中注释掉了<%= stylesheet_link_tag“屏幕”,:media =>“screen”%>代码。
  2. I didn't have 'rubyracer' gem installed. 我没有安装'rubyracer'宝石。 I installed it because it was in the gem profiled of the referenced answer. 我安装它是因为它在引用答案的gem profile中。 I have no clue what it does. 我不知道它的作用。
  3. The URL slashes ("/") are now showing up again wherever I have links. 现在,只要有链接,URL斜杠(“/”)就会再次出现。 My hunch is that it's something in one of the CSS files that I'm just going to have to dive into and debug. 我的预感是,它只是我需要深入研究和调试的一个CSS文件中的内容。 But, the whole reason I had the stylesheet_link_tag thing in the first place was because I was trying to get rid of those pesky slashes. 但是,我首先得到stylesheet_link_tag事情的全部原因是因为我试图摆脱那些讨厌的斜线。 Ultimately, I decided deployment was more important. 最终,我认为部署更重要。

Hope this is helpful to someone else! 希望这对其他人有帮助!

Here's how I ultimately solved the problem(s). 以下是我最终解决问题的方法。 Thanks to the folks who referred me elsewhere so that I could put it all together. 感谢那些把我推荐到别处的人,以便我可以把它们放在一起。

First, I moved Blueprint to a vender directory. 首先,我将Blueprint移动到了一个供应商目录。 I don't think that's crucial to the solution, but it felt cleaner. 我不认为这对解决方案至关重要,但感觉更清洁。

The compilation problem: 编译问题:

This thread: blueprint css rails 3.1 help was really helpful. 这个主题: 蓝图css rails 3.1帮助真的很有帮助。 I found Martin and Gary's responses (nos 2 and 3) more helpful than the selected response. 我发现Martin和Gary的回答(第2和第3条)比选择的回答更有帮助。

Part of why I was having trouble with compilation (personally) is because I made some edits to the Blueprint files, which meant that they needed to be compiled again before deployment. 我编译(个人)的部分原因是因为我对Blueprint文件进行了一些编辑,这意味着他们需要在部署之前再次编译。

This thread: rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled) was helpful in that regard. 这个线程: rails 3.1.0 ActionView :: Template :: Error(application.css未预编译)在这方面很有帮助。 Basically, just run "Bundle exec rake assets:precompile" before uploading to heroku. 基本上,在上传到heroku之前,只需运行“Bundle exec rake assets:precompile”。 I also run "heroku run rake assets:precompile" after upload. 上传后我还运行“heroku run rake assets:precompile”。

How I got rid of the URL slashes in my links: The URLs are the result of this code in Blueprint/print.css: 如何删除链接中的URL斜杠: URL是Blueprint / print.css中此代码的结果:

a:link, a:visited {background:transparent;font-weight:700;text-decoration:underline;}
a:link:after, a:visited:after {content:" (" attr(href) ")";font-size:90%;}

I solved the problem by commenting out that code. 我通过注释掉那段代码解决了这个问题。 Of course, after changing the file, you have to rake assets:precompile again. 当然,在更改文件后,您必须耙资产:再次预编译。 But, that got it all working! 但是,这一切都有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM