Class: Hercules::Hercules

Inherits:
Object
  • Object
show all
Defined in:
lib/hercules.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, stdin) ⇒ Hercules

Returns a new instance of Hercules.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hercules.rb', line 18

def initialize(arguments, stdin)
  @arguments = arguments
  @stdin = stdin

  # Set default options
  @options = OpenStruct.new
  @options.config_file = 'config.yml'
  @options.verbose = false
  @options.log_file = nil
  @options.pid_file = 'hercules.pid'
  @options.foreground = false

  @config = nil
  @pid_file = nil
  @log = nil
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/hercules.rb', line 16

def options
  @options
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/hercules.rb', line 35

def run
  parse_options
  set_logger
  read_config
  be_verbose if @options.verbose

  # if -f is not present we fork into the background and write hercules.pid
  @options.foreground ? process_command : daemonize
  @log.close  
end