提问人:jtlwell 提问时间:10/30/2023 最后编辑:jtlwell 更新时间:11/1/2023 访问量:48
如何修复崩溃的 ruby on rails 应用程序上的 heroku H10/应用程序错误?
How to fix a heroku H10/Application error on a ruby on rails application which is crashing?
问:
在过去的 4 个小时里,我一直在尝试修复 heroku(ruby on rails 应用程序)上的应用程序错误,但没有运气。
P.S 该应用程序在本地运行良好
2023-10-30T14:40:44.484063+00:00 heroku[web.1]: State changed from up to crashed
2023-10-30T14:40:44.378048+00:00 heroku[router]: at=info method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=2b4b5435-b40a-431c-b48f-1159fa5fd7fb fwd="86.182.36.176" dyno=web.1 connect=0ms service=107ms status=101 bytes=174 protocol=https
2023-10-30T14:41:19.466343+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=41cf02af-42a1-43b5-9ac8-7d6fbf8ac59f fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
2023-10-30T14:41:19.652461+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=3fd8c5e8-b470-4c2c-86cd-a6c5ac86246b fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
2023-10-30T14:41:27.250890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=255ce216-77ae-465a-9abb-f32e5b027221 fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
我多次尝试重新启动 heroku,确保我的 storage.yml 文件格式正确,在 heroku 控制台中没有发现错误。这可能与我的procfile有关,但是我尝试的所有内容都返回相同的错误。我还重新启动了heroku界面上的所有网络测功机。
Procfile: web:捆绑 exec puma -C config/puma.rb
gem文件:
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'sqlite3'
ruby "3.1.2"
gem "devise"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.7", ">= 7.0.7.2"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use postgresql as the database for Active Record
# gem "pg", "~> 1.1"
group :production do
gem 'pg'
gem 'redis', '~> 4.0'
end
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
# Use Sass to process CSS
gem "sassc-rails"
gem 'sidekiq'
gem 'thin'
# added faker
gem "faker"
gem "rails-ujs"
# spotify api
# gem 'rack-cors'
# gem 'active_model_serializers'
# gem 'rspotify'
# added cloudinary
gem "cloudinary"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem "bootstrap", "~> 5.2"
gem "autoprefixer-rails"
gem "font-awesome-sass", "~> 6.1"
gem "simple_form", github: "heartcombo/simple_form"
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "dotenv-rails"
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
end
答:
0赞
jtlwell
11/1/2023
#1
解决方案:我已经修复了该应用程序。问题是我的 puma 文件是在应该生产的时候为开发而设置的。我项目中的 Procfile 为“web”进程类型指定了一个命令,该命令负责运行应用程序服务器。
命令“bundle exec puma -C config/puma.rb”告诉 Puma 如何启动应用程序。但是,我注意到 Puma 文件 (config/puma.rb) 中的配置是为开发而设置的。
为了确保正确的生产设置,我调整了 config/puma.rb 文件中的 Puma 配置,以符合生产环境的要求。
我所做的只是更改它说开发到生产的地方,并取消注释掉preload_app!这是我现在的 Puma 文件:
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "production") == "production"
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "production" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
preload_app!
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
上一个:RAILS 6 构建失败
下一个:关于 Heroku CLI 错误
评论