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
|
end
|
||||||
|
|
||||||
if Sidekiq.server?
|
if Sidekiq.server?
|
||||||
|
|
||||||
# warm up AR
|
# warm up AR
|
||||||
RailsMultisite::ConnectionManagement.each_connection do
|
RailsMultisite::ConnectionManagement.each_connection do
|
||||||
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
||||||
|
@ -24,6 +23,9 @@ if Sidekiq.server?
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.application.config.after_initialize do
|
Rails.application.config.after_initialize do
|
||||||
|
scheduler_hostname = ENV["UNICORN_SCHEDULER_HOSTNAME"]
|
||||||
|
|
||||||
|
if !scheduler_hostname || scheduler_hostname == `hostname`.strip
|
||||||
require 'scheduler/scheduler'
|
require 'scheduler/scheduler'
|
||||||
manager = Scheduler::Manager.new
|
manager = Scheduler::Manager.new
|
||||||
Scheduler::Manager.discover_schedules.each do |schedule|
|
Scheduler::Manager.discover_schedules.each do |schedule|
|
||||||
|
@ -42,6 +44,7 @@ if Sidekiq.server?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Sidekiq.logger.level = Logger::WARN
|
Sidekiq.logger.level = Logger::WARN
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue