【问题标题】:How to deploy Michael Hartl's Rails Tutorial App on Heroku using Puma如何使用 Puma 在 Heroku 上部署 Michael Hartl 的 Rails 教程应用程序
【发布时间】:2015-04-28 15:05:21
【问题描述】:

我是新来的,如果我的帖子不符合标准,我深表歉意。

我在做 Mike Hartl 的 Rails 教程,在第 7 章结束时,我对 heroku 的推动不起作用。 Heroku 状态

"应用程序错误应用程序和您的页面发生错误 无法送达。请稍后再试。

如果您是应用程序所有者,请查看您的日志以了解详细信息。”

它在本地运行良好,但我不确定是什么原因导致它在第 6 章结束时运行良好。我认为这是我的 gem 文件中的内容,但我注释掉了添加的两个 gem,它确实一样。

Heroku 日志:

2015-04-28T08:16:49.294539+00:00 heroku[web.1]: Starting process with command        `bundle exec puma -C config/puma.rb`
2015-04-28T08:16:51.465325+00:00 app[web.1]: /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `read': No such file or directory - config/puma.rb (Errno::ENOENT)
2015-04-28T08:16:51.465349+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-04-28T08:16:51.465353+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-04-28T08:16:51.465355+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-04-28T08:16:51.465359+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-04-28T08:16:51.465357+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-04-28T08:16:51.465361+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `load'
2015-04-28T08:16:51.465364+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
2015-04-28T08:16:52.165317+00:00 heroku[web.1]: Process exited with status 1
2015-04-28T08:16:52.205397+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-28T08:16:52.206353+00:00 heroku[web.1]: State changed from crashed to starting
2015-04-28T08:16:55.767400+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2015-04-28T08:16:58.099736+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:453:in `run'
2015-04-28T08:16:58.099709+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in   `read': No such file or directory - config/puma.rb (Errno::ENOENT)
2015-04-28T08:16:58.099730+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:179:in `_load_from'
2015-04-28T08:16:58.099732+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/configuration.rb:40:in `load'
2015-04-28T08:16:58.099737+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/bin/puma:10:in `<top (required)>'
2015-04-28T08:16:58.099734+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/gems/puma-2.11.1/lib/puma/cli.rb:308:in `parse_options'
2015-04-28T08:16:58.099739+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `load'
2015-04-28T08:16:58.099743+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.0.0/bin/puma:23:in `<main>'
2015-04-28T08:16:58.871301+00:00 heroku[web.1]: Process exited with status 1
2015-04-28T08:16:58.885119+00:00 heroku[web.1]: State changed from starting to crashed
2015-04-28T08:17:43.314547+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by jeryl.barnum@gmail.com
2015-04-28T08:17:47.723769+00:00 heroku[run.3182]: Awaiting client
2015-04-28T08:17:47.792818+00:00 heroku[run.3182]: Starting process with command `bundle exec rake db:migrate`
2015-04-28T08:17:48.168224+00:00 heroku[run.3182]: State changed from starting to up
2015-04-28T08:17:55.295889+00:00 heroku[run.3182]: State changed from up to complete
2015-04-28T08:17:55.255648+00:00 heroku[run.3182]: Process exited with status 0
2015-04-28T08:17:56.062422+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=friendapp.herokuapp.com request_id=04e23ecb-9945-4e49-a6c7-a8f96bf11a54 fwd="96.41.41.110" dyno= connect= service= status=503 bytes=
2015-04-28T08:17:57.164362+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=friendapp.herokuapp.com request_id=8e2f6e75-dabe-4377-a449-5f9d8414f49d fwd="96.41.41.110" dyno= connect= service= status=503 bytes=
2015-04-28T08:17:59.359063+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=friendapp.herokuapp.com request_id=bfc919b3-ed3c-4964-8190-961ca690cdca fwd="96.41.41.110" dyno= connect= service= status=503 bytes=
2015-04-28T08:17:59.954515+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=friendapp.herokuapp.com request_id=61f2b1d4-570e-47bd-91c1-3189ea8b5565 fwd="96.41.41.110" dyno= connect= service= status=503 bytes=
2015-04-28T08:18:02.043668+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=friendapp.herokuapp.com request_id=0ca8cede-33b8-42b4-865c-5cdc28596c55 fwd="96.41.41.110" dyno= connect= service= status=503 bytes=
2015-04-28T08:18:02.583384+00:00 heroku[router]: at=error code=H10 desc="App     crashed" method=GET path="/favicon.ico" host=friendapp.herokuapp.com request_id=c53a196d-b2f8-4bf9-94fc-acc94c705391 fwd="96.41.41.110" dyno= connect= service= status=503 bytes=

用户模型:

class User < ActiveRecord::Base
 before_save { self.email = email.downcase }
 validates :name, presence: true, length: { maximum: 50 }
 VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
 validates :email, presence: true, length: {maximum: 200 },
        format: { with: VALID_EMAIL_REGEX },
        uniqueness: { case_sensitve: false }
 has_secure_password
 validates :password, length: { minimum: 5 }
end

宝石文件:

source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'bootstrap-sass',       '3.2.0.0'
gem 'pg'
gem 'bcrypt',               '3.1.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'rails_12factor'
gem 'puma',           '2.11.1'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end

我是不是好像遗漏了什么?自从我取出 Puma gem 后,我取出了我的 Procfile,但这似乎并没有什么不同。不确定我是否还需要包含任何其他文件...

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: ruby-on-rails heroku railstutorial.org


    【解决方案1】:

    是的,您好像缺少 config/ 文件夹中的 puma 配置。

    No such file or directory - config/puma.rb (Errno::ENOENT)
    

    来自 heroku 文档:

    https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#config

    在 config/puma.rb 或您选择的路径中为 Puma 创建一个配置文件。对于一个简单的 Rails 应用,我们推荐以下基本配置:

    workers Integer(ENV['WEB_CONCURRENCY'] || 2)
    threads_count = Integer(ENV['MAX_THREADS'] || 5)
    threads threads_count, threads_count
    
    preload_app!
    
    rackup      DefaultRackup
    port        ENV['PORT']     || 3000
    environment ENV['RACK_ENV'] || 'development'
    
    on_worker_boot do
      # Worker specific setup for Rails 4.1+
      # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
      ActiveRecord::Base.establish_connection
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-20
      • 2016-04-06
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多