Skip to content

Commit

Permalink
💄
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Cantero committed Feb 13, 2017
1 parent f75a943 commit 31e5239
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
10 changes: 4 additions & 6 deletions lib/shoryuken/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def run(args)

@launcher = Shoryuken::Launcher.new

if callback = Shoryuken.start_callback
if (callback = Shoryuken.start_callback)
logger.info { 'Calling Shoryuken.on_start block' }
callback.call
end
Expand Down Expand Up @@ -103,11 +103,9 @@ def daemonize(options)
end

def write_pid(options)
if (path = options[:pidfile])
File.open(path, 'w') do |f|
f.puts Process.pid
end
end
return unless (path = options[:pidfile])

File.open(path, 'w') { |f| f.puts(Process.pid) }
end

def parse_cli_args(argv)
Expand Down
17 changes: 6 additions & 11 deletions lib/shoryuken/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@ def initialize

raise(ArgumentError, "Concurrency value #{count} is invalid, it needs to be a positive number") unless count > 0

@managers = Array.new(count) do
Shoryuken::Manager.new(1,
Shoryuken::Fetcher.new,
Shoryuken.options[:polling_strategy].new(Shoryuken.queues))
end
@manager = Shoryuken::Manager.new(count,
Shoryuken::Fetcher.new,
Shoryuken.options[:polling_strategy].new(Shoryuken.queues))
end

def stop(options = {})
@managers.map do |manager|
Thread.new { manager.stop(shutdown: !!options[:shutdown], timeout: Shoryuken.options[:timeout]) }
end.each(&:join)
@manager.stop(shutdown: !options[:shutdown].nil?,
timeout: Shoryuken.options[:timeout])
end

def run
@managers.map do |manager|
Thread.new { manager.start }
end.each(&:join)
@manager.start
end
end
end

0 comments on commit 31e5239

Please sign in to comment.