mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
34 lines
870 B
Ruby
34 lines
870 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Sidekiq
|
|
class Rails < ::Rails::Engine
|
|
config.after_initialize do
|
|
# This hook happens after all initializers are run, just before returning
|
|
# from config/environment.rb back to sidekiq/cli.rb.
|
|
# We have to add the reloader after initialize to see if cache_classes has
|
|
# been turned on.
|
|
#
|
|
# None of this matters on the client-side, only within the Sidekiq process itself.
|
|
#
|
|
Sidekiq.configure_server do |_|
|
|
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
|
end
|
|
end
|
|
|
|
class Reloader
|
|
def initialize(app = ::Rails.application)
|
|
@app = app
|
|
end
|
|
|
|
def call
|
|
@app.reloader.wrap do
|
|
yield
|
|
end
|
|
end
|
|
|
|
def inspect
|
|
"#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
|
|
end
|
|
end
|
|
end
|
|
end
|