FIX: disable scheduled jobs when in readonly mode
This commit is contained in:
parent
19c630e7c2
commit
fbacaab2fc
|
@ -197,6 +197,11 @@ module Jobs
|
||||||
|
|
||||||
class Scheduled < Base
|
class Scheduled < Base
|
||||||
extend Scheduler::Schedule
|
extend Scheduler::Schedule
|
||||||
|
|
||||||
|
def perform(*args)
|
||||||
|
return if Discourse.readonly_mode?
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enqueue(job_name, opts={})
|
def self.enqueue(job_name, opts={})
|
||||||
|
|
|
@ -10,7 +10,6 @@ module Scheduler
|
||||||
class Manager
|
class Manager
|
||||||
attr_accessor :random_ratio, :redis
|
attr_accessor :random_ratio, :redis
|
||||||
|
|
||||||
|
|
||||||
class Runner
|
class Runner
|
||||||
def initialize(manager)
|
def initialize(manager)
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
|
@ -157,7 +156,6 @@ module Scheduler
|
||||||
lock do
|
lock do
|
||||||
schedule_info(klass).schedule!
|
schedule_info(klass).schedule!
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove(klass)
|
def remove(klass)
|
||||||
|
@ -203,8 +201,8 @@ module Scheduler
|
||||||
|
|
||||||
def schedule_next_job(hostname=nil)
|
def schedule_next_job(hostname=nil)
|
||||||
(key, due), _ = redis.zrange Manager.queue_key(hostname), 0, 0, withscores: true
|
(key, due), _ = redis.zrange Manager.queue_key(hostname), 0, 0, withscores: true
|
||||||
|
|
||||||
return unless key
|
return unless key
|
||||||
|
|
||||||
if due.to_i <= Time.now.to_i
|
if due.to_i <= Time.now.to_i
|
||||||
klass = get_klass(key)
|
klass = get_klass(key)
|
||||||
unless klass
|
unless klass
|
||||||
|
|
|
@ -68,15 +68,13 @@ end
|
||||||
# server middleware that will reschedule work whenever Sidekiq is paused
|
# server middleware that will reschedule work whenever Sidekiq is paused
|
||||||
class Sidekiq::Pausable
|
class Sidekiq::Pausable
|
||||||
|
|
||||||
attr_reader :delay
|
|
||||||
|
|
||||||
def initialize(delay = 5.seconds)
|
def initialize(delay = 5.seconds)
|
||||||
@delay = delay
|
@delay = delay
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(worker, msg, queue)
|
def call(worker, msg, queue)
|
||||||
if Sidekiq.paused?
|
if Sidekiq.paused?
|
||||||
worker.class.perform_in(delay, *msg['args'])
|
worker.class.perform_in(@delay, *msg['args'])
|
||||||
else
|
else
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue