correct multisite issues with scheduler
This commit is contained in:
parent
61f32ed431
commit
9b4fd0b26b
|
@ -25,7 +25,7 @@ if Sidekiq.server?
|
||||||
|
|
||||||
if !scheduler_hostname || scheduler_hostname.split(',').include?(`hostname`.strip)
|
if !scheduler_hostname || scheduler_hostname.split(',').include?(`hostname`.strip)
|
||||||
require 'scheduler/scheduler'
|
require 'scheduler/scheduler'
|
||||||
manager = Scheduler::Manager.new
|
manager = Scheduler::Manager.new($redis.without_namespace)
|
||||||
Scheduler::Manager.discover_schedules.each do |schedule|
|
Scheduler::Manager.discover_schedules.each do |schedule|
|
||||||
manager.ensure_schedule!(schedule)
|
manager.ensure_schedule!(schedule)
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,12 +106,17 @@ module Scheduler
|
||||||
info.prev_result = failed ? "FAILED" : "OK"
|
info.prev_result = failed ? "FAILED" : "OK"
|
||||||
info.current_owner = nil
|
info.current_owner = nil
|
||||||
if stat
|
if stat
|
||||||
stat.update!(
|
begin
|
||||||
duration_ms: duration,
|
RailsMultisite::ConnectionManagement.establish_connection(db: "default")
|
||||||
live_slots_finish: GC.stat[:heap_live_slots],
|
stat.update!(
|
||||||
success: !failed,
|
duration_ms: duration,
|
||||||
error: error
|
live_slots_finish: GC.stat[:heap_live_slots],
|
||||||
)
|
success: !failed,
|
||||||
|
error: error
|
||||||
|
)
|
||||||
|
ensure
|
||||||
|
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
attempts(3) do
|
attempts(3) do
|
||||||
@mutex.synchronize { info.write! }
|
@mutex.synchronize { info.write! }
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Scheduler
|
||||||
|
|
||||||
data = nil
|
data = nil
|
||||||
|
|
||||||
if data = $redis.get(key)
|
if data = @manager.redis.get(key)
|
||||||
data = JSON.parse(data)
|
data = JSON.parse(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ module Scheduler
|
||||||
current_owner: @current_owner
|
current_owner: @current_owner
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
||||||
redis.zadd queue_key, @next_run , @klass if @next_run
|
redis.zadd queue_key, @next_run, @klass if @next_run
|
||||||
end
|
end
|
||||||
|
|
||||||
def del!
|
def del!
|
||||||
|
|
Loading…
Reference in New Issue