2013-03-25 09:26:13 -05:00
|
|
|
sidekiq_redis = { url: $redis.url, namespace: 'sidekiq' }
|
2013-02-05 13:16:51 -06:00
|
|
|
|
2013-08-07 12:25:05 -05:00
|
|
|
Sidekiq.configure_server do |config|
|
|
|
|
config.redis = sidekiq_redis
|
|
|
|
end
|
|
|
|
|
2014-02-05 17:14:41 -06:00
|
|
|
if Sidekiq.server?
|
2014-02-07 22:18:54 -06:00
|
|
|
|
|
|
|
# warm up AR
|
|
|
|
RailsMultisite::ConnectionManagement.each_connection do
|
|
|
|
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
|
|
|
table.classify.constantize.first rescue nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-05 17:14:41 -06:00
|
|
|
require 'scheduler/scheduler'
|
|
|
|
|
|
|
|
manager = Scheduler::Manager.new
|
|
|
|
Scheduler::Manager.discover_schedules.each do |schedule|
|
|
|
|
manager.ensure_schedule!(schedule)
|
|
|
|
end
|
|
|
|
Thread.new do
|
|
|
|
while true
|
|
|
|
begin
|
|
|
|
manager.tick
|
|
|
|
rescue => e
|
|
|
|
# the show must go on
|
|
|
|
Scheduler::Manager.handle_exception(e)
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
end
|
|
|
|
end
|
2013-09-02 02:14:41 -05:00
|
|
|
end
|
2013-05-29 11:36:15 -05:00
|
|
|
|
2013-09-02 02:14:41 -05:00
|
|
|
Sidekiq.configure_client { |config| config.redis = sidekiq_redis }
|
2013-05-29 11:36:15 -05:00
|
|
|
Sidekiq.logger.level = Logger::WARN
|
2014-02-05 17:14:41 -06:00
|
|
|
|