Приложение Heroku rails запускается локально, но при открытии выдает код ошибки приложения H10 - PullRequest
0 голосов
/ 05 апреля 2020

У меня есть приложение Rails, которое успешно работает локально и которое я успешно отправил на свой пульт Heroku. Однако, когда я открываю URL, я получаю ошибку приложения. Если я посмотрю на свои логи heroku, то вот что я вижу:

2020-04-04T23:52:16.920545+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=srseats.herokuapp.com request_id=f9130218-18f9-43b4-9fe7-0b04a0ed5555 fwd="107.137.41.186" dyno= connect= service= status=503 bytes= protocol=http
2020-04-04T23:52:17.490055+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=srseats.herokuapp.com request_id=9928310f-cc3e-4161-89eb-3db5cd527650 fwd="107.137.41.186" dyno= connect= service= status=503 bytes= protocol=http
2020-04-04T23:59:13.244533+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-04T23:59:22.120784+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-04T23:59:22.054662+00:00 app[web.1]: (erb):19:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
2020-04-04T23:59:22.054723+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/erb.rb:876:in `eval'
2020-04-04T23:59:22.054724+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/erb.rb:876:in `result'
2020-04-04T23:59:22.054728+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/lib/active_storage/engine.rb:95:in `block (2 levels) in <class:Engine>'
2020-04-04T23:59:22.054734+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
2020-04-04T23:59:22.054735+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'

Если я запустил heroku run rails console, я получу тот же неопределенный метод `[] 'для ошибки nil: NilClass, что и выше:

Traceback (most recent call last):
        83: from /app/bin/rails:9:in `<main>'
        82: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
        81: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
        80: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
        79: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        78: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        77: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        76: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        75: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        74: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
        73: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
        72: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
        71: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        70: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        69: from /app/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        68: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/commands/console/console_command.rb:95:in `perform'
        67: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
        66: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/command/actions.rb:28:in `require_environment!'
        65: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
        64: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
        63: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
        62: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
        61: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        60: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        59: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        58: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        57: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        56: from /app/config/environment.rb:5:in `<top (required)>'
        55: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
        54: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
        53: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
        52: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
        51: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
        50: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call'
        49: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each'
        48: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
        47: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
        46: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        45: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
        44: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
        43: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
        42: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
        41: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
        40: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:69:in `each'
        39: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:356:in `eager_load!'
        38: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:475:in `eager_load!'
        37: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:475:in `each'
        36: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:477:in `block in eager_load!'
        35: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:477:in `each'
        34: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
        33: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:246:in `require_dependency'
        32: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:85:in `depend_on'
        31: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:334:in `depend_on'
        30: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:47:in `require_or_load'
        29: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:16:in `allow_bootsnap_retry'
        28: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:48:in `block in require_or_load'
        27: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:356:in `require_or_load'
        26: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `load_interlock'
        25: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
        24: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
        23: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
        22: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
        21: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
        20: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
        19: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
        18: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
        17: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        16: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
        15: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        14: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
        13: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
        12: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/app/models/active_storage/blob.rb:16:in `<top (required)>'
        11: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/app/models/active_storage/blob.rb:235:in `<class:Blob>'
        10: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
         9: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
         8: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
         7: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
         6: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
         5: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
         4: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
         3: from /app/vendor/bundle/ruby/2.5.0/gems/activestorage-5.2.3/lib/active_storage/engine.rb:95:in `block (2 levels) in <class:Engine>'
         2: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/erb.rb:876:in `result'
         1: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/erb.rb:876:in `eval'
(erb):19:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

У меня есть догадка, что это связано с использованием ActiveStorage, но я не совсем уверен, но вот мой storage.yml

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
# amazon:
#   service: S3
#   access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
#   secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
#   region: us-east-1
#   bucket: your_own_bucket

amazon_dev:
  service: S3
  access_key_id: <%= Rails.application.credentials.aws[:access_key_id] %>
  secret_access_key: <%= Rails.application.credentials.aws[:secret_access_key] %>
  region: <%= Rails.application.credentials.aws[:region] %>
  bucket: <%= Rails.application.credentials.aws[:dev][:bucket] %>

amazon_prod:
  service: S3
  access_key_id: <%= Rails.application.credentials.aws[:access_key_id] %>
  secret_access_key: <%= Rails.application.credentials.aws[:secret_access_key] %>
  region: <%= Rails.application.credentials.aws[:region] %>
  bucket: <%= Rails.application.credentials.aws[:prod][:bucket] %>

Любые советы или помощь будет принята с благодарностью. Благодаря.

1 Ответ

0 голосов
/ 27 апреля 2020

Я только что решил, возможно, ту же проблему. Оказывается, у меня не было главного ключа Rails, установленного в Heroku. Вот информация, которая сработала для меня:

... мы сделаем момент, чтобы сделать абсолютно необходимый шаг, чтобы Active Storage работала с Heroku. Heroku сможет дешифровать ваш credentials.yml.en c только в том случае, если мы добавим наш мастер-ключ (который можно найти в config / master.key). Тем не менее, мастер-ключ Gitignored по уважительной причине. Не проверяйте этот файл в git. Мы можем использовать командную строку heroku, чтобы тайно добавить ключ в нашу конфигурацию heroku.

$ heroku config:set RAILS_MASTER_KEY=<your-master-key-here>

Если вы не сделаете это, Active Storage не будет работать на Heroku и вызовет тонна бесполезных ошибок.

...