mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Try running once off jobs outside of db:migrate
This commit is contained in:
parent
078b3bc87e
commit
3f7ced9236
3 changed files with 21 additions and 6 deletions
|
@ -10,15 +10,21 @@ class Jobs::Onceoff < Jobs::Base
|
||||||
job_name = self.class.name_for(self.class)
|
job_name = self.class.name_for(self.class)
|
||||||
|
|
||||||
if args[:force] || !OnceoffLog.where(job_name: job_name).exists?
|
if args[:force] || !OnceoffLog.where(job_name: job_name).exists?
|
||||||
execute_onceoff(args)
|
DistributedMutex.synchronize(self.class.name) do
|
||||||
OnceoffLog.create(job_name: job_name)
|
execute_onceoff(args)
|
||||||
|
OnceoffLog.create(job_name: job_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.enqueue_all
|
def self.enqueue_all
|
||||||
|
previously_ran = OnceoffLog.pluck(:job_name).uniq
|
||||||
|
|
||||||
ObjectSpace.each_object(Class).select { |klass| klass < self }.each do |klass|
|
ObjectSpace.each_object(Class).select { |klass| klass < self }.each do |klass|
|
||||||
job_name = name_for(klass).underscore.to_sym
|
job_name = name_for(klass)
|
||||||
Jobs.enqueue(job_name)
|
unless previously_ran.include?(job_name)
|
||||||
|
Jobs.enqueue(job_name.underscore.to_sym)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
11
app/jobs/scheduled/enqueue_onceoffs.rb
Normal file
11
app/jobs/scheduled/enqueue_onceoffs.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
module Jobs
|
||||||
|
|
||||||
|
class EnqueueOnceoffs < Jobs::Scheduled
|
||||||
|
every 10.minutes
|
||||||
|
|
||||||
|
def execute(args)
|
||||||
|
Jobs::Onceoff.enqueue_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -7,8 +7,6 @@ end
|
||||||
task 'db:migrate' => ['environment', 'set_locale'] do
|
task 'db:migrate' => ['environment', 'set_locale'] do
|
||||||
SeedFu.seed
|
SeedFu.seed
|
||||||
|
|
||||||
Jobs::Onceoff.enqueue_all
|
|
||||||
|
|
||||||
SiteSetting.last_vacuum = Time.now.to_i if SiteSetting.last_vacuum == 0
|
SiteSetting.last_vacuum = Time.now.to_i if SiteSetting.last_vacuum == 0
|
||||||
|
|
||||||
if SiteSetting.vacuum_db_days > 0 &&
|
if SiteSetting.vacuum_db_days > 0 &&
|
||||||
|
|
Loading…
Reference in a new issue