2013-01-29 11:15:34 -05:00
|
|
|
require 'sidekiq/util'
|
|
|
|
require 'sidekiq/manager'
|
|
|
|
require 'sidekiq/scheduled'
|
|
|
|
|
|
|
|
module Sidekiq
|
|
|
|
class Launcher
|
|
|
|
attr_reader :manager, :poller, :options
|
|
|
|
def initialize(options)
|
|
|
|
@options = options
|
|
|
|
@manager = Sidekiq::Manager.new(options)
|
|
|
|
@poller = Sidekiq::Scheduled::Poller.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
manager.async.start
|
|
|
|
poller.async.poll(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop
|
|
|
|
poller.async.terminate if poller.alive?
|
|
|
|
manager.async.stop(:shutdown => true, :timeout => options[:timeout])
|
|
|
|
manager.wait(:shutdown)
|
|
|
|
end
|
2013-01-29 11:43:44 -05:00
|
|
|
|
|
|
|
def procline(tag)
|
|
|
|
$0 = manager.procline(tag)
|
|
|
|
manager.after(5) { procline(tag) }
|
|
|
|
end
|
2013-01-29 11:15:34 -05:00
|
|
|
end
|
|
|
|
end
|