Heroku应用程序错误应用程序不上线



好吧,我正在尝试使用 Heroku 部署我的应用程序,但我遇到了一些错误,我的互联网挖掘不足以解决。部署运行正常,显示已成功:

remote: Verifying deploy... done.
To https://git.heroku.com/MYAPPHERE.git
7715c7c..c85251d  master -> master

但是当我转到域时,它会显示以下消息:

"应用程序错误,应用程序中发生错误,无法提供您的页面。如果您是应用程序所有者,请检查您的日志以了解详细信息。

我的日志显示:

018-05-18T19:14:24.000000+00:00 app[api]: Build succeeded
2018-05-18T19:14:28.864974+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2018-05-18T19:14:31.064709+00:00 app[web.1]: [4] Puma starting in cluster mode...
2018-05-18T19:14:31.064729+00:00 app[web.1]: [4] * Version 3.11.4 (ruby 2.3.1-p112), codename: Love Song
2018-05-18T19:14:31.064730+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5
2018-05-18T19:14:31.064732+00:00 app[web.1]: [4] * Environment: production
2018-05-18T19:14:31.064752+00:00 app[web.1]: [4] * Process workers: 2
2018-05-18T19:14:31.064776+00:00 app[web.1]: [4] * Preloading application
2018-05-18T19:14:33.736893+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:36902
2018-05-18T19:14:33.737145+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:36902
2018-05-18T19:14:33.737416+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.3.0/bin/puma)
2018-05-18T19:14:33.737462+00:00 app[web.1]: Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 36902
2018-05-18T19:14:33.737465+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:270:in `initialize'
2018-05-18T19:14:33.737466+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:270:in `new'
2018-05-18T19:14:33.737468+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:270:in `add_tcp_listener'
2018-05-18T19:14:33.737469+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:105:in `block in parse'
2018-05-18T19:14:33.737471+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:88:in `each'
2018-05-18T19:14:33.737472+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/binder.rb:88:in `parse'
2018-05-18T19:14:33.737474+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/runner.rb:144:in `load_and_bind'
2018-05-18T19:14:33.737475+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/cluster.rb:397:in `run'
2018-05-18T19:14:33.737477+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/launcher.rb:184:in `run'
2018-05-18T19:14:33.737478+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/cli.rb:78:in `run'
2018-05-18T19:14:33.737480+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/bin/puma:10:in `<top (required)>'
2018-05-18T19:14:33.737482+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/bin/puma:23:in `load'
2018-05-18T19:14:33.737483+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/bin/puma:23:in `<top (required)>'
2018-05-18T19:14:33.833127+00:00 heroku[web.1]: State changed from starting to up
2018-05-18T19:14:33.953708+00:00 heroku[web.1]: State changed from up to crashed
2018-05-18T19:14:33.931364+00:00 heroku[web.1]: Process exited with status 1
2018-05-18T19:14:35.621801+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=MYAPPNAME request_id=74c67c85-dce7-4da8-9770-f41513d8cf31 fwd="179.178.13.25" dyno= connect= service= status=503 bytes= protocol=https

在我的宝石文件上:

# Use Puma as the app server
gem 'puma', '~> 3.7'

在配置/彪马上:

plugin :tmp_restart
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_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

我看到地址发生了错误,但我根本不使用此地址。我尝试运行lsof -wni tcp:36902,但它什么也没显示。

希望我提供了足够的信息。

似乎 puma 试图绑定听众两次:

2018-05-18T19:14:33.736893+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:36902
2018-05-18T19:14:33.737145+00:00 app[web.1]: [4] * Listening on tcp://0.0.0.0:36902

您可能想尝试将preload_app!移动到端口和环境配置下方。(通过调用端口,它可能调用两个类似于此处的绑定函数(

我目前正在运行带有美洲狮 3.11.4 的 Heroku,我的config/puma.rb看起来像:

threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
threads threads_count, threads_count
environment ENV.fetch('RAILS_ENV', 'development')
port        ENV.fetch('PORT', 3000)
workers ENV.fetch('WEB_CONCURRENCY', 2)
preload_app!
before_fork do
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

查看您的 Procfile 也可能有所帮助。 只是想确认它看起来像这样:

一个简单的Procfile可能是:

web: bundle exec puma -C config/puma.rb

相关内容

  • 没有找到相关文章

最新更新