Add ENV variable to only allow Sidekiq scheduler to run on a particular host.
This commit is contained in:
parent
c3b5bca0e8
commit
f499180bb3
|
@ -15,7 +15,6 @@ Sidekiq.configure_server do |config|
|
|||
end
|
||||
|
||||
if Sidekiq.server?
|
||||
|
||||
# warm up AR
|
||||
RailsMultisite::ConnectionManagement.each_connection do
|
||||
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
||||
|
@ -24,6 +23,9 @@ if Sidekiq.server?
|
|||
end
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
scheduler_hostname = ENV["UNICORN_SCHEDULER_HOSTNAME"]
|
||||
|
||||
if !scheduler_hostname || scheduler_hostname == `hostname`.strip
|
||||
require 'scheduler/scheduler'
|
||||
manager = Scheduler::Manager.new
|
||||
Scheduler::Manager.discover_schedules.each do |schedule|
|
||||
|
@ -41,6 +43,7 @@ if Sidekiq.server?
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Sidekiq.logger.level = Logger::WARN
|
||||
|
|
Loading…
Reference in New Issue