mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:44:49 +08:00
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
|
||||
extend Scheduler::Schedule
|
||||
|
||||
def perform(*args)
|
||||
return if Discourse.readonly_mode?
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.enqueue(job_name, opts={})
|
||||
|
|
|
@ -10,7 +10,6 @@ module Scheduler
|
|||
class Manager
|
||||
attr_accessor :random_ratio, :redis
|
||||
|
||||
|
||||
class Runner
|
||||
def initialize(manager)
|
||||
@mutex = Mutex.new
|
||||
|
@ -157,7 +156,6 @@ module Scheduler
|
|||
lock do
|
||||
schedule_info(klass).schedule!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def remove(klass)
|
||||
|
@ -203,8 +201,8 @@ module Scheduler
|
|||
|
||||
def schedule_next_job(hostname=nil)
|
||||
(key, due), _ = redis.zrange Manager.queue_key(hostname), 0, 0, withscores: true
|
||||
|
||||
return unless key
|
||||
|
||||
if due.to_i <= Time.now.to_i
|
||||
klass = get_klass(key)
|
||||
unless klass
|
||||
|
|
|
@ -68,15 +68,13 @@ end
|
|||
# server middleware that will reschedule work whenever Sidekiq is paused
|
||||
class Sidekiq::Pausable
|
||||
|
||||
attr_reader :delay
|
||||
|
||||
def initialize(delay = 5.seconds)
|
||||
@delay = delay
|
||||
end
|
||||
|
||||
def call(worker, msg, queue)
|
||||
if Sidekiq.paused?
|
||||
worker.class.perform_in(delay, *msg['args'])
|
||||
worker.class.perform_in(@delay, *msg['args'])
|
||||
else
|
||||
yield
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user