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

Returns a new instance of DispatcherOptions.



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
254
255
256
257
258
259
260
# File 'lib/bricolage/streamingload/dispatcher.rb', line 228

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.



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

def environment
  @environment
end

#log_file_pathObject (readonly)

Returns the value of attribute log_file_path.



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

def log_file_path
  @log_file_path
end

#pid_file_pathObject (readonly)

Returns the value of attribute pid_file_path.



279
280
281
# File 'lib/bricolage/streamingload/dispatcher.rb', line 279

def pid_file_path
  @pid_file_path
end

#rest_argumentsObject (readonly)

Returns the value of attribute rest_arguments.



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

def rest_arguments
  @rest_arguments
end

#task_idObject (readonly)

Returns the value of attribute task_id.



281
282
283
# File 'lib/bricolage/streamingload/dispatcher.rb', line 281

def task_id
  @task_id
end

Instance Method Details

#daemon?Boolean

Returns:

  • (Boolean)


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

def daemon?
  @daemon
end

#parseObject



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

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

#usageObject



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

def usage
  @opts.help
end