【问题标题】:Trying to figure out why my rails app crashes in heroku?试图弄清楚为什么我的 rails 应用程序在 heroku 中崩溃?
【发布时间】:2018-08-07 20:53:41
【问题描述】:

我是 heroku 的新手,第一次尝试部署 Rails 应用程序。当我打开它时,它崩溃了。这是日志,只是想知道是否有人能理解它?

 018-02-28T03:49:38.908155+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
2018-02-28T03:49:38.908156+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
2018-02-28T03:49:38.908160+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-02-28T03:49:38.917703+00:00 app[web.1]: => Booting Puma
2018-02-28T03:49:38.908161+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-02-28T03:49:38.908153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-02-28T03:49:38.917707+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-02-28T03:49:38.917709+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-02-28T03:49:38.917710+00:00 app[web.1]: Exiting
2018-02-28T03:50:00.911567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=d5674160-7991-4e20-a8c2-9037cd14fca0 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:50:02.294872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=5aac6d0b-2974-40ac-8fc3-fd314fcedba2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2018-02-28T03:49:38.908155+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
2018-02-28T03:49:38.908156+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
2018-02-28T03:49:38.908160+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-02-28T03:49:38.917703+00:00 app[web.1]: => Booting Puma
2018-02-28T03:49:38.908161+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-02-28T03:49:38.908153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-02-28T03:49:38.917707+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-02-28T03:49:38.917709+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-02-28T03:49:38.917710+00:00 app[web.1]: Exiting
2018-02-28T03:50:00.911567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=d5
674160-7991-4e20-a8c2-9037cd14fca0 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:50:02.294872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=5aac6d0b-2974-40ac-8fc3-fd314fcedba2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2018-02-28T03:49:38.908155+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
2018-02-28T03:49:38.908156+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
2018-02-28T03:49:38.908160+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-02-28T03:49:38.917703+00:00 app[web.1]: => Booting Puma
2018-02-28T03:49:38.908161+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-02-28T03:49:38.908153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-02-28T03:49:38.917707+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-02-28T03:49:38.917709+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-02-28T03:49:38.917710+00:00 app[web.1]: Exiting
2018-02-28T03:50:00.911567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=d5
674160-7991-4e20-a8c2-9037cd14fca0 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:50:02.294872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=5aac6d0b-2974-40ac-8fc3-fd314fcedba2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:46.845758+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=f695bff2-745d-4f14-af52-55b246316e7a fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:50.098411+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=b7af71af-e036-47b3-8c35-d9f841971cd2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2018-02-28T03:49:38.908160+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-02-28T03:49:38.917703+00:00 app[web.1]: => Booting Puma
2018-02-28T03:49:38.908161+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-02-28T03:49:38.908153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-02-28T03:49:38.917707+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-02-28T03:49:38.917709+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-02-28T03:49:38.917710+00:00 app[web.1]: Exiting
2018-02-28T03:50:00.911567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=d5674160-7991-4e20-a8c2-9037cd14fca0 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:50:02.294872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=5aac6d0b-2974-40ac-8fc3-fd314fcedba2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:46.845758+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=f695bff2-745d-4f14-af52-55b246316e7a fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:50.098411+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=b7af71af-e036-47b3-8c35-d9f841971cd2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2018-02-28T03:49:38.908160+00:00 app[web.1]:    from bin/rails:9:in `require'
2018-02-28T03:49:38.917703+00:00 app[web.1]: => Booting Puma
2018-02-28T03:49:38.908161+00:00 app[web.1]:    from bin/rails:9:in `<main>'
2018-02-28T03:49:38.908153+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
2018-02-28T03:49:38.917707+00:00 app[web.1]: => Rails 5.1.4 application starting in production 
2018-02-28T03:49:38.917709+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-02-28T03:49:38.917710+00:00 app[web.1]: Exiting
2018-02-28T03:50:00.911567+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=d5674160-7991-4e20-a8c2-9037cd14fca0 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:50:02.294872+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=5aac6d0b-2974-40ac-8fc3-fd314fcedba2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:46.845758+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fidirect-api.herokuapp.com request_id=f695bff2-745d-4f14-af52-55b246316e7a fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https
2018-02-28T03:52:50.098411+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fidirect-api.herokuapp.com request_id=b7af71af-e036-47b3-8c35-d9f841971cd2 fwd="199.116.73.196" dyno= connect= service= status=503 bytes= protocol=https

【问题讨论】:

  • 此应用部署正确吗?
  • 是的。当我在终端中运行 heroku run rails console 时,我收到一条错误消息,指出 postgresql 被指定为数据库适配器,但它不包含在 gemfile 中。但是,我刚刚检查了 gemfile 和 gemfile.lock 及其两者。我按照heroku的要求将数据库从sqlite切换到postgres,但我不确定这是否会导致问题
  • 部署后是否运行heroku run rake db:migrate
  • 当我这样做时,我得到了同样的错误:
  • Gem::LoadError: 为数据库适配器指定了“postgresql”,但未加载 gem。将gem 'pg' 添加到您的 Gemfile(并确保其版本为 ActiveRecord 要求的最低版本)。

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


【解决方案1】:

您需要在本地安装postgres,因为没有postgres,您将无法安装pg gem。所以在安装postgres 之后安装pg gem 所以bundler 在你的Gemfile.lock 中输入了条目。 heroku 的问题是在部署到 heroku 之前必须在本地安装所有 gem,因为 heroku 会读取您的 Gemfile.lock 文件来安装依赖项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-14
    • 1970-01-01
    相关资源
    最近更新 更多