Class: Bricolage::StreamingLoad::DispatcherOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/streamingload/dispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ DispatcherOptions



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/bricolage/streamingload/dispatcher.rb', line 221

def initialize(argv)
  @argv = argv
  @daemon = false
  @log_file_path = nil
  @pid_file_path = nil
  @task_id = nil
  @rest_arguments = nil

  @opts = opts = OptionParser.new("Usage: #{$0} CONFIG_PATH")
  opts.on('-e', '--environment=NAME', "Sets execution environment [default: #{Context::DEFAULT_ENV}]") {|env|
    @environment = env
  }
  opts.on('--daemon', 'Becomes daemon in server mode.') {
    @daemon = true
  }
  opts.on('--log-file=PATH', 'Log file path') {|path|
    @log_file_path = path
  }
  opts.on('--pid-file=PATH', 'Creates PID file.') {|path|
    @pid_file_path = path
  }
  opts.on('--task-id=ID', 'Dispatches this task and quit.') {|id|
    @task_id = id.to_i
  }
  opts.on('--help', 'Prints this message and quit.') {
    puts opts.help
    exit 0
  }
  opts.on('--version', 'Prints version and quit.') {
    puts "#{File.basename($0)} version #{VERSION}"
    exit 0
  }
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



266
267
268
# File 'lib/bricolage/streamingload/dispatcher.rb', line 266

def environment
  @environment
end

#log_file_pathObject (readonly)

Returns the value of attribute log_file_path.



266
267
268
# File 'lib/bricolage/streamingload/dispatcher.rb', line 266

def log_file_path
  @log_file_path
end

#pid_file_pathObject (readonly)

Returns the value of attribute pid_file_path.



272
273
274
# File 'lib/bricolage/streamingload/dispatcher.rb', line 272

def pid_file_path
  @pid_file_path
end

#rest_argumentsObject (readonly)

Returns the value of attribute rest_arguments.



266
267
268
# File 'lib/bricolage/streamingload/dispatcher.rb', line 266

def rest_arguments
  @rest_arguments
end

#task_idObject (readonly)

Returns the value of attribute task_id.



274
275
276
# File 'lib/bricolage/streamingload/dispatcher.rb', line 274

def task_id
  @task_id
end

Instance Method Details

#daemon?Boolean



268
269
270
# File 'lib/bricolage/streamingload/dispatcher.rb', line 268

def daemon?
  @daemon
end

#parseObject



259
260
261
262
263
264
# File 'lib/bricolage/streamingload/dispatcher.rb', line 259

def parse
  @opts.parse!(@argv)
  @rest_arguments = @argv.dup
rescue OptionParser::ParseError => err
  raise OptionError, err.message
end

#usageObject



255
256
257
# File 'lib/bricolage/streamingload/dispatcher.rb', line 255

def usage
  @opts.help
end