Start async adapters after_initialize
instead of once Active Job and Active Record are loaded and Rails initialized?
#1297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem with when Async Adapters are started has overall been vexing. Problems like #930 have been reported, and I experienced this in #1294.
The unfortunate part of this is that
Rails.application.initialized?
isn't hookable and allafter_initialize
callbacks happen before tha becomes true.The major change here is that GoodJob is now initialized before Puma finishes booting, which means that sometimes GoodJob will run before the Puma banner is output.
Why did this work before? In some apps,
ActiveRecord::Base
would not be loaded during initialization. Then, during the first web request and afterinitialized?
the hook would be called and GoodJob's async adapters would start.Why didn't this work before? In other apps,
ActiveRecord::Base
would be loaded during initialization and beforeinitialized?
. This led to GoodJob's async adapters never being started.