Class: Upstart::Exporter::Options::Global

Inherits:
Hash
  • Object
show all
Includes:
Errors
Defined in:
lib/upstart-exporter/options/global.rb

Constant Summary collapse

DEFAULTS =
{
  'helper_dir' => '/var/local/upstart_helpers/',
  'upstart_dir' => '/etc/init/',
  'run_user' => 'service',
  'run_group' => 'service',
  'prefix' => 'fb-',
  'start_on_runlevel' => '[3]',
  'stop_on_runlevel' => '[3]',
  'kill_timeout' => 30
}
CONF =
'/etc/upstart-exporter.yaml'

Instance Method Summary collapse

Methods included from Errors

#error

Constructor Details

#initializeGlobal

Returns a new instance of Global.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/upstart-exporter/options/global.rb', line 18

def initialize
  super
  config = if FileTest.file?(CONF)
    YAML::load(File.read(CONF))
  else
    $stderr.puts "#{CONF} not found"
    {}
  end
  error "#{CONF} is not a valid YAML config" unless config.is_a?(Hash)
  DEFAULTS.keys.each do |param|
    value = if config[param]
      config[param]
    else
      $stderr.puts "Param #{param} is not set, taking default value #{DEFAULTS[param]}"
      DEFAULTS[param]
    end
    self[param.to_sym] = value
  end
end