Rails 4.1.1(ruby 2.1.2)应用程序不会在Heroku app dyno上运行

时间:2014-05-23 09:37:01

标签: ruby-on-rails ruby heroku ruby-on-rails-4

我遇到了一些麻烦(第二天我正在尝试),只需将rails的基本应用程序结构部署到heroku。基于这个基本结构,我后来想要做一些改变和改进工作,但对于初学者我只想验证它是否正常工作。

我的步骤: 1.我之前安装了一些ruby和rails,但是我按照本指南安装了最新的稳定红宝石和导轨:http://railsapps.github.io/installing-rails.html 2.我有一个〜/ ruby​​ / myapp文件夹,其中我有以下版本:

ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
Rails 4.1.1
  1. 我使用
  2. 在此文件夹中创建了新项目
      

    rails new。

    1. 获得了项目结构。然后将其提交给Git存储库。
    2. 根据this指南,我已将pg和rails_12factor添加到Gemfile并重新发送给Git。
    3. 此时应用程序正在我的localhost上启动。
    4. 我创建了heroku应用程序并将我的git代码提交给它。它运行了bundle install。
    5. 当我的应用程序已经无法在heroku上运行时到达此时,我看到它运行ruby 2.0.0的捆绑日志。所以在heroku支持页面之后添加了
    6.   

      ruby​​ 2.1.2

      到Gemfile - 再次提交 Heroku再次运行bundle install

      1. heroku是否运行rake db:migrate以防万一 - 构建数据库等等。
      2. 仍然是heroku应用说:
      3.   

        您要查找的页面不存在。

             

        您可能输错了地址或页面可能已移动。

             

        如果您是应用程序所有者,请检查日志以获取更多信息。

        查看heroku日志时,请输入以下消息:

        2014-05-23T07:53:34.704093+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
        2014-05-23T07:53:34.704091+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
        2014-05-23T07:53:34.704095+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:38:in `call_app'
        2014-05-23T07:53:34.704097+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `block in call'
        2014-05-23T07:53:34.704098+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
        2014-05-23T07:53:34.704100+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:26:in `tagged'
        2014-05-23T07:53:34.704102+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/tagged_logging.rb:68:in `tagged'
        2014-05-23T07:53:34.704103+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/rack/logger.rb:20:in `call'
        2014-05-23T07:53:34.704105+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
        2014-05-23T07:53:34.704106+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
        2014-05-23T07:53:34.704108+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
        2014-05-23T07:53:34.704110+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
        2014-05-23T07:53:34.704122+00:00 app[web.1]:   vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
        2014-05-23T07:53:34.704123+00:00 app[web.1]:   vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
        2014-05-23T07:53:34.704125+00:00 app[web.1]:   vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
        2014-05-23T07:53:34.704126+00:00 app[web.1]: 
        2014-05-23T07:53:34.704111+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.1/lib/action_dispatch/middleware/static.rb:64:in `call'
        2014-05-23T07:53:34.704113+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
        2014-05-23T07:53:34.704114+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/engine.rb:514:in `call'
        2014-05-23T07:53:34.704116+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/application.rb:144:in `call'
        2014-05-23T07:53:34.704117+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call'
        2014-05-23T07:53:34.704119+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
        2014-05-23T07:53:34.704120+00:00 app[web.1]:   vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
        2014-05-23T07:53:34.704127+00:00 app[web.1]: 
        2014-05-23T07:53:30.745345+00:00 heroku[run.4509]: Process exited with status 0
        2014-05-23T08:53:56.212847+00:00 heroku[web.1]: Idling
        2014-05-23T08:53:56.213402+00:00 heroku[web.1]: State changed from up to down
        2014-05-23T08:54:00.182694+00:00 app[web.1]: [2014-05-23 08:54:00] FATAL SignalException: SIGTERM
        2014-05-23T08:54:00.182702+00:00 app[web.1]:    /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:170:in `block in start'
        2014-05-23T08:54:00.182700+00:00 app[web.1]:    /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:170:in `select'
        2014-05-23T08:54:00.182706+00:00 app[web.1]:    /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:160:in `start'
        2014-05-23T08:54:00.182711+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/server.rb:69:in `start'
        2014-05-23T08:54:00.182704+00:00 app[web.1]:    /app/vendor/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:32:in `start'
        2014-05-23T08:54:00.182708+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:14:in `run'
        2014-05-23T08:54:00.182713+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:81:in `block in server'
        2014-05-23T08:54:00.182715+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
        2014-05-23T08:54:00.182716+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
        2014-05-23T08:54:00.182718+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        2014-05-23T08:54:00.182719+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        2014-05-23T08:54:00.182721+00:00 app[web.1]:    bin/rails:8:in `require'
        2014-05-23T08:54:00.182722+00:00 app[web.1]:    bin/rails:8:in `<main>'
        2014-05-23T08:54:00.182756+00:00 app[web.1]: [2014-05-23 08:54:00] INFO  going to shutdown ...
        2014-05-23T08:54:00.182847+00:00 app[web.1]: [2014-05-23 08:54:00] INFO  WEBrick::HTTPServer#start done.
        2014-05-23T08:54:00.182883+00:00 app[web.1]: Exiting
        2014-05-23T08:54:00.182709+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
        2014-05-23T08:54:01.539311+00:00 heroku[web.1]: Process exited with status 143
        2014-05-23T08:53:59.404723+00:00 heroku[web.1]: Stopping all processes with SIGTERM
        

        我非常感谢你的帮助,因为这是我第二天尝试通过查看论坛(SE)来完成一项简单的任务,而不是。并没有效果。虽然我在更新到ruby 2.1.2和rails 4.1.1之前尝试过至少4-5次。之后几次。

        我对这个配置奥德赛变得非常非常沮丧。

        ====== 这里也是git push heroku master的输出

        git push heroku master
        Fetching repository, done.
        Counting objects: 9, done.
        Delta compression using up to 2 threads.
        Compressing objects: 100% (5/5), done.
        Writing objects: 100% (5/5), 584 bytes, done.
        Total 5 (delta 4), reused 0 (delta 0)
        
        -----> Ruby app detected
        -----> Compiling Ruby/Rails
        -----> Using Ruby version: ruby-2.1.2
        -----> Installing dependencies using 1.5.2
               Ruby version change detected. Clearing bundler cache.
               Old: ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-linux]
               New: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
               Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
               Fetching gem metadata from https://rubygems.org/..........
               Fetching additional metadata from https://rubygems.org/..
               Using json (1.8.1)
               Installing minitest (5.3.4)
               Installing thread_safe (0.3.3)
               Installing i18n (0.6.9)
               Installing rake (10.3.2)
               Installing builder (3.2.2)
               Installing rack (1.5.2)
               Installing mime-types (1.25.1)
               Installing erubis (2.7.0)
               Installing polyglot (0.3.4)
               Installing coffee-script-source (1.7.0)
               Installing arel (5.0.1.20140414130214)
               Installing execjs (2.0.2)
               Installing thor (0.19.1)
               Using bundler (1.5.2)
               Installing hike (1.2.3)
               Installing multi_json (1.10.1)
               Installing tilt (1.4.1)
               Installing rails_serve_static_assets (0.0.2)
               Installing rails_stdout_logging (0.0.3)
               Installing sass (3.2.19)
               Installing tzinfo (1.1.0)
               Installing rdoc (4.1.1)
               Installing rack-test (0.6.2)
               Installing treetop (1.4.15)
               Installing coffee-script (2.2.0)
               Installing uglifier (2.5.0)
               Installing sprockets (2.11.0)
               Installing rails_12factor (0.0.2)
               Installing activesupport (4.1.1)
               Installing sdoc (0.4.0)
               Installing mail (2.5.4)
               Installing actionview (4.1.1)
               Installing activemodel (4.1.1)
               Installing jbuilder (2.0.7)
               Installing actionpack (4.1.1)
               Installing activerecord (4.1.1)
               Installing actionmailer (4.1.1)
               Installing railties (4.1.1)
               Installing sprockets-rails (2.1.3)
               Installing coffee-rails (4.0.1)
               Installing jquery-rails (3.1.0)
               Installing turbolinks (2.2.2)
               Installing rails (4.1.1)
               Installing sass-rails (4.0.3)
               Installing pg (0.17.1)
               Your bundle is complete!
               Gems in the groups development and test were not installed.
               It was installed into ./vendor/bundle
               Post-install message from rdoc:
               Depending on your version of ruby, you may need to install ruby rdoc/ri data:
               <= 1.8.6 : unsupported
               = 1.8.7 : gem install rdoc-data; rdoc-data --install
               = 1.9.1 : gem install rdoc-data; rdoc-data --install
               >= 1.9.2 : nothing to do! Yay!
               Bundle completed (27.87s)
               Cleaning up the bundler cache.
        -----> Preparing app for Rails asset pipeline
               Running: rake assets:precompile
               Asset precompilation completed (3.54s)
               Cleaning assets
               Running: rake assets:clean
        -----> WARNINGS:
               No Procfile detected, using the default web server (webrick)
               https://devcenter.heroku.com/articles/ruby-default-web-server
        -----> Discovering process types
               Procfile declares types -> (none)
               Default types for Ruby  -> console, rake, web, worker
        
        -----> Compressing... done, 22.0MB
        -----> Launching... done, v7
               http://cookingdice.herokuapp.com/ deployed to Heroku
        
        To git@heroku.com:cookingdice.git
           432b16d..1d2b762  master -> master
        

2 个答案:

答案 0 :(得分:1)

您收到的错误消息是来自rails的404错误,在生产中您没有看到rails欢迎页面。

如果您创建一个简单的HomeController并渲染Hi或者其他内容,并将其设置为您的根URL,它可能会有效!

应用/控制器/ home_controller.rb

class HomeController < ApplicationController
  def index
  end
end

应用/视图/家/ index.html.erb

<p>Hi</p>`

<强>配置/ routes.rb中

root to: 'home#index'`

答案 1 :(得分:0)

您是否可以修改production.rb以确保提供静态资产:

config.serve_static_assets = true

尝试将以下内容添加到Gemfile中:

gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'

您正在使用Webrick服务器,尝试使用独角兽,使Gemfile制作组如下:

group :production do
  gem 'pg' 
  gem 'unicorn' 
  gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'
  gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'
end