2015-12-31 15:33:35 -08:00
|
|
|
# frozen_string_literal: true
|
2018-12-07 17:59:42 +01:00
|
|
|
|
2012-01-25 13:32:51 -08:00
|
|
|
module Sidekiq
|
|
|
|
class Rails < ::Rails::Engine
|
2016-10-01 08:27:54 +10:00
|
|
|
config.after_initialize do
|
2016-12-12 09:39:12 -08:00
|
|
|
# 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 |_|
|
2018-12-28 10:16:50 -08:00
|
|
|
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
2016-10-01 08:27:54 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-01 15:59:20 -08:00
|
|
|
class Reloader
|
|
|
|
def initialize(app = ::Rails.application)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call
|
2016-04-28 10:02:03 -07:00
|
|
|
@app.reloader.wrap do
|
|
|
|
yield
|
2016-02-01 15:59:20 -08:00
|
|
|
end
|
|
|
|
end
|
2016-04-28 10:38:46 -07:00
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
|
|
|
|
end
|
2016-02-01 15:59:20 -08:00
|
|
|
end
|
2018-12-28 10:16:50 -08:00
|
|
|
end
|
2018-12-07 17:59:42 +01:00
|
|
|
end
|