Class: Kriterion::CLI::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/kriterion/cli/worker.rb

Class Method Summary collapse

Class Method Details

.commandObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kriterion/cli/worker.rb', line 6

def self.command
  @cmd ||= Cri::Command.define do
    name        'worker'
    usage       'worker --uri <uri>'
    summary     'Runs a kriterion worker'

    flag   :h,  :help,  'show help for this command' do |value, cmd|
      puts cmd.help
      exit 0
    end

    optional :u, :uri           , 'URI of the RestMQ server'             , default: ENV['uri'] || 'http://localhost:8888'
    optional :q, :queue         , 'Queue to subscribe to'                , default: ENV['queue']|| 'reports'
    optional :h, :mongo_hostname, 'Hostname of the MongoDB server to use', default: ENV['mongo_hostname']|| 'localhost'
    optional :d, :mongo_database, 'Name of the MongoDB database to use'  , default: ENV['mongo_database']|| 'kriterion'
    optional :p, :mongo_port    , 'Port for MongoDB'                     , default: ENV['mongo_port']|| 27017


    run do |opts, args, cmd|
      require 'kriterion/worker'
      worker = Kriterion::Worker.new(opts)
      worker.run
    end
  end
end