简体   繁体   中英

Why Heroku unable to start worker?

I have a Rails app deployed to heroku but it doesn't work. Here is what i got in heroku logs --tail

2022-07-06T09:59:13.574745+00:00 heroku[web.1]: State changed from down to starting
2022-07-06T09:59:23.970068+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-production}`
2022-07-06T09:59:25.559635+00:00 app[web.1]: [4] Puma starting in cluster mode...
2022-07-06T09:59:25.559650+00:00 app[web.1]: [4] * Puma version: 5.6.4 (ruby 3.1.0-p0) ("Birdie's Version")
2022-07-06T09:59:25.559651+00:00 app[web.1]: [4] *  Min threads: 5
2022-07-06T09:59:25.559651+00:00 app[web.1]: [4] *  Max threads: 5
2022-07-06T09:59:25.559651+00:00 app[web.1]: [4] *  Environment: production
2022-07-06T09:59:25.559654+00:00 app[web.1]: [4] *   Master PID: 4
2022-07-06T09:59:25.559656+00:00 app[web.1]: [4] *      Workers: 1
2022-07-06T09:59:25.559667+00:00 app[web.1]: [4] *     Restarts: (✔) hot (✔) phased
2022-07-06T09:59:25.559897+00:00 app[web.1]: [4] * Listening on http://0.0.0.0:58774
2022-07-06T09:59:25.559980+00:00 app[web.1]: [4] Use Ctrl-C to stop
2022-07-06T09:59:25.559982+00:00 app[web.1]: [4] ! WARNING: Detected running cluster mode with 1 worker.
2022-07-06T09:59:25.559994+00:00 app[web.1]: [4] ! Running Puma in cluster mode with a single worker is often a misconfiguration.
2022-07-06T09:59:25.560005+00:00 app[web.1]: [4] ! Consider running Puma in single-mode (workers = 0) in order to reduce memory overhead.
2022-07-06T09:59:25.560016+00:00 app[web.1]: [4] ! Set the `silence_single_worker_warning` option to silence this warning message.
2022-07-06T09:59:25.912808+00:00 heroku[web.1]: State changed from starting to up
2022-07-06T09:59:28.766096+00:00 app[web.1]: I, [2022-07-06T09:59:28.765979 #12]  INFO -- : Raven 3.1.2 configured not to capture errors: No host specified, no public_key specified, no project_id specified
2022-07-06T09:59:29.209929+00:00 app[web.1]: [12] ! Unable to start worker
2022-07-06T09:59:29.209957+00:00 app[web.1]: [12] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require'
2022-07-06T09:59:29.219542+00:00 app[web.1]: [12] Early termination of worker
2022-07-06T09:59:30.545562+00:00 app[web.1]: I, [2022-07-06T09:59:30.545446 #15]  INFO -- : Raven 3.1.2 configured not to capture errors: No host specified, no public_key specified, no project_id specified
2022-07-06T09:59:30.755168+00:00 app[web.1]: [15] ! Unable to start worker
2022-07-06T09:59:30.755180+00:00 app[web.1]: [15] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require'
2022-07-06T09:59:30.755349+00:00 app[web.1]: [15] Early termination of worker
2022-07-06T09:59:31.000000+00:00 app[api]: Build succeeded
2022-07-06T09:59:31.913137+00:00 app[web.1]: I, [2022-07-06T09:59:31.913027 #18]  INFO -- : Raven 3.1.2 configured not to capture errors: No host specified, no public_key specified, no project_id specified
2022-07-06T09:59:32.184897+00:00 app[web.1]: [18] ! Unable to start worker
2022-07-06T09:59:32.184916+00:00 app[web.1]: [18] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:27:in `require'
2022-07-06T09:59:32.185115+00:00 app[web.1]: [18] Early termination of worker
2022-07-06T09:59:33.514705+00:00 app[web.1]: I, [2022-07-06T09:59:33.514563 #21]  INFO -- : Raven 3.1.2 configured not to capture errors: No host specified, no public_key specified, no project_id specified

Also I have had a same problem in my RSpec test:

An error occurred while loading ./spec/api/v1/action_items_spec.rb.
Failure/Error: require File.expand_path('../config/environment', __dir__)

NoMethodError:
  undefined method `driver_path=' for Selenium::WebDriver::Chrome:Module

  Selenium::WebDriver::Chrome.driver_path=Gem.bin_path("chromedriver-helper","chromedriver-helper")
                             ^^^^^^^^^^^^^
# /bundle/ruby/3.1.0/gems/chromedriver-helper-2.1.1/lib/chromedriver-helper.rb:4:in `<top (required)>'
# /bundle/ruby/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
# /bundle/ruby/3.1.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'

As you can see, the text of the error is the same, except for the line on which it occurs: 27 и 30

I solved the test problem by downgrading the Selenium gem. However, this did not solve the error on Heroku. Why does she appear?

config/puma.rb

# frozen_string_literal: true

# 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.
#
threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
threads threads_count, threads_count

# 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', 'development')

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver 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 `rails restart` command.
plugin :tmp_restart

Procfile

web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-production}
worker: bundle exec sidekiq

Try to add workers Integer(ENV.fetch('WEB_CONCURRENCY') || 2) in config/puma.rb

Uncomment preload_app!

In Procfile add -c 2 to worker: bundle exec sidekiq

Add 'net/pop' gem to Gemfile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM