correct multisite issues with scheduler

This commit is contained in:
Sam 2017-10-11 18:46:53 +11:00
parent 61f32ed431
commit 9b4fd0b26b
3 changed files with 14 additions and 9 deletions

View File

@ -25,7 +25,7 @@ if Sidekiq.server?
if !scheduler_hostname || scheduler_hostname.split(',').include?(`hostname`.strip)
require 'scheduler/scheduler'
manager = Scheduler::Manager.new
manager = Scheduler::Manager.new($redis.without_namespace)
Scheduler::Manager.discover_schedules.each do |schedule|
manager.ensure_schedule!(schedule)
end

View File

@ -106,12 +106,17 @@ module Scheduler
info.prev_result = failed ? "FAILED" : "OK"
info.current_owner = nil
if stat
stat.update!(
duration_ms: duration,
live_slots_finish: GC.stat[:heap_live_slots],
success: !failed,
error: error
)
begin
RailsMultisite::ConnectionManagement.establish_connection(db: "default")
stat.update!(
duration_ms: duration,
live_slots_finish: GC.stat[:heap_live_slots],
success: !failed,
error: error
)
ensure
ActiveRecord::Base.connection_handler.clear_active_connections!
end
end
attempts(3) do
@mutex.synchronize { info.write! }

View File

@ -12,7 +12,7 @@ module Scheduler
data = nil
if data = $redis.get(key)
if data = @manager.redis.get(key)
data = JSON.parse(data)
end
@ -100,7 +100,7 @@ module Scheduler
current_owner: @current_owner
}.to_json
redis.zadd queue_key, @next_run , @klass if @next_run
redis.zadd queue_key, @next_run, @klass if @next_run
end
def del!