Sha256: 3f70db154e3ead4bbc723c1004ca1734a9ddc24dd9962e49a14ee42317f9e574

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module Upstart::Exporter::Options
  class Global < Hash
    include Upstart::Exporter::Errors

    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,
      :respawn => {
        :count => 5,
        :interval => 10
      }
    }

    CONF = '/etc/upstart-exporter.yaml'

    def initialize
      super
      config = if FileTest.file?(CONF)
        Upstart::Exporter::HashUtils.symbolize_keys(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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upstart-exporter-2.1.5 lib/upstart-exporter/options/global.rb
upstart-exporter-2.1.4 lib/upstart-exporter/options/global.rb
upstart-exporter-2.1.3 lib/upstart-exporter/options/global.rb