class Jobly::Commands::WorkerCmd

Public Instance Methods

run() click to toggle source
# File lib/jobly/commands/worker.rb, line 15
def run
  say "Starting sidekiq"
  exec "sidekiq #{options_from_args}"
end

Private Instance Methods

boot_file() click to toggle source
# File lib/jobly/commands/worker.rb, line 39
def boot_file
  @boot_file ||= File.expand_path '../boot.rb', __dir__
end
options_from_args() click to toggle source
# File lib/jobly/commands/worker.rb, line 22
def options_from_args
  result = []
  result << "--environment #{Jobly.environment}"
  result << "--require \"#{boot_file}\""
  result << "--concurrency #{args['--concurrency']}" if args['--concurrency']

  if args['--config']
    config_file = "#{Jobly.config_path}/#{args['--config']}.yml"
    raise ArgumentError, "Config not found: #{config_file}" unless File.exist? config_file
    result << "--config \"#{config_file}\""
  end
  
  args['--queue'].each { |q| result << "--queue #{q}" }

  result.join ' '
end