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.



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
261
# File 'lib/bricolage/streamingload/dispatcher.rb', line 229

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.



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

def environment
  @environment
end

#log_file_pathObject (readonly)

Returns the value of attribute log_file_path.



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

def log_file_path
  @log_file_path
end

#pid_file_pathObject (readonly)

Returns the value of attribute pid_file_path.



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

def pid_file_path
  @pid_file_path
end

#rest_argumentsObject (readonly)

Returns the value of attribute rest_arguments.



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

def rest_arguments
  @rest_arguments
end

#task_idObject (readonly)

Returns the value of attribute task_id.



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

def task_id
  @task_id
end

Instance Method Details

#daemon?Boolean

Returns:

  • (Boolean)


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

def daemon?
  @daemon
end

#parseObject



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

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

#usageObject



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

def usage
  @opts.help
end