mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
13c940eb7d
We don't want to touch the process name if we're integrating Sidekiq into existing process, so better not to put procline assignment in Manager, but in CLI where we launch standalone Sidekiq process.
31 lines
676 B
Ruby
31 lines
676 B
Ruby
|
|
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
|
|
|
|
def procline(tag)
|
|
$0 = manager.procline(tag)
|
|
manager.after(5) { procline(tag) }
|
|
end
|
|
end
|
|
end
|