/usr/lib/ruby/vendor_ruby/raemon/configuration.rb is in ruby-raemon 0.3.0+git.2012.05.18.b78eaae57c-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | module Raemon
##
# Manages configuration settings and defaults
module Configuration
extend self
DEFAULT_SERVER_NAME = 'Raemon'
DEFAULT_DETACH = false
DEFAULT_NUM_WORKERS = 1
DEFAULT_TIMEOUT = 3 * 60 # 3 minutes
DEFAULT_MEMORY_LIMIT_IN_MEGABYTES = 50
DEFAULT_ENVIRONMENT = 'development'
DEFAULT_LOG_LEVEL = :info
DEFAULT_INSTRUMENTOR_NAME = 'raemon'
attr_accessor :settings
@settings = {}
# Define a configuration option with a default.
#
# @example Define the option.
# Config.option(:server_name, default: "Raemon")
#
# @param [Symbol] name The name of the configuration option
#
# @param [Hash] options Extras for the option
#
# @note Copied from Mongoid. Thank you!
#
# @private
def option(name, options = {})
define_method(name) do
settings.has_key?(name) ? settings[name] : options[:default]
end
define_method("#{name}=") { |value| settings[name] = value }
define_method("#{name}?") { !!send(name) }
end
option :server_name, :default => DEFAULT_SERVER_NAME
option :detach, :default => DEFAULT_DETACH
option :num_workers, :default => DEFAULT_NUM_WORKERS
option :timeout, :default => DEFAULT_TIMEOUT
option :env, :default => DEFAULT_ENVIRONMENT
option :memory_limit, :default => DEFAULT_MEMORY_LIMIT_IN_MEGABYTES
option :worker_class
option :instrumentor
option :instrumentor_name, :default => DEFAULT_INSTRUMENTOR_NAME
option :on_stop, :default => Proc.new {}
# @param [Logger] logger Some logger to use with this library
def logger=(logger)
@logger = logger
end
# @return [logger] The logger used by this library
def logger
@logger ||= setup_logger
end
# @param [String] root The root path for this application
def root=(root)
@root = root
end
# @return [Pathname] the root path for this application
def root
if @root.nil?
raise 'Raemon::Config.root must be set'
else
Pathname.new(@root).expand_path
end
end
private
def setup_logger
target = detach ? root.join("log/#{env}.log") : STDOUT
@logger = ::Logger.new(target)
@logger.formatter = ::Logger::Formatter.new
@logger
end
end
end
|