Zero processes in development with async mode #1185
-
I have tried for a while to find out what went wrong, but I need to ask for help here since I was not able to find out. # application.rb
config.active_job.queue_adapter = :good_job
# initializers/good_job.rb
config.good_job.preserve_job_records = true
config.good_job.retry_on_unhandled_error = false
config.good_job.queues = '*'
config.good_job.max_threads = 5
config.good_job.poll_interval = 30 # seconds
config.good_job.shutdown_timeout = 25 # seconds
config.good_job.enable_cron = true
config.good_job.cron = {
...
}
config.good_job.queue_select_limit = 1000
config.good_job.smaller_number_is_higher_priority = true
config.good_job.on_thread_error = -> (exception) {
Sentry.capture_exception(exception)
}
# Do not log arguments passed to jobs to prevent logging user passwords
config.active_job.log_arguments = false I have read the hint on the readme saying "Because of Rails deferred autoloading, jobs enqueued via the rails console may not begin executing on a separate server process until the Rails application is fully initialized by loading a web page once." So, after What did I miss? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Re-enqueuing a cron entry did start a worker process, but the cron entries fail to enqueue themselves and start before the worker process is started. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing these details:
I do think that should be sufficient, but having GoodJob detect it's in a webserver is very tricky. If you're using Puma, it's best to be explicit about starting GoodJob in your Otherwise, you can do some good_job/lib/good_job/engine.rb Lines 51 to 69 in ae74482 Here's how it initializes Active Job / Adapters: good_job/lib/good_job/dependencies.rb Lines 18 to 26 in ae74482 And here's how it determines if it's inside a webserver: good_job/lib/good_job/dependencies.rb Lines 18 to 26 in ae74482 |
Beta Was this translation helpful? Give feedback.
Thanks for sharing these details:
I do think that should be sufficient, but having GoodJob detect it's in a webserver is very tricky.
If you're using Puma, it's best to be explicit about starting GoodJob in your
config/puma.rb
file. Here are some examples: https://github.com/bensheldon/good_job#execute-jobs-async--in-processOtherwise, you can do some
puts
debugging on Rails initializers. Here's what GoodJob waits for during initialization:good_job/lib/good_job/engine.rb
Lines 51 to 69 in ae74482