Class: DaemonKit::Configuration
- Includes:
- Configurable
- Defined in:
- lib/daemon_kit/initializer.rb
Overview
Holds our various configuration values
Instance Attribute Summary collapse
-
#load_paths ⇒ Object
List of load paths.
-
#log_level ⇒ Object
The log level to use, defaults to DEBUG.
-
#log_stdout ⇒ Object
Duplicate log data to stdout.
-
#logger ⇒ Object
Custom logger instance to use.
-
#pid_file ⇒ Object
Path to the pid file, defaults to ‘log/<daemon_name>.pid’.
-
#root_path ⇒ Object
readonly
Root to the daemon.
-
#safety_net ⇒ Object
Our safety net (#Safety) instance.
-
#shutdown_hooks ⇒ Object
readonly
:nodoc: Shutdown hooks.
-
#signal_traps ⇒ Object
readonly
Collection of signal traps.
Instance Method Summary collapse
-
#at_shutdown(proc = nil, &block) ⇒ Object
Add a block or proc to be called during shutdown.
- #daemon_initializer ⇒ Object
- #environment ⇒ Object
-
#environment_path ⇒ Object
The path to the current environment’s file (
development.rb
, etc.). -
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#trap(signal, proc = nil, &block) ⇒ Object
Add a trap for the specified signal, can be code block or a proc.
Methods included from Configurable
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/daemon_kit/initializer.rb', line 293 def initialize parse_arguments! set_root_path! set_daemon_defaults! self.load_paths = default_load_paths self.log_level ||= default_log_level self.log_path ||= default_log_path self.force_kill_wait = false self.safety_net = DaemonKit::Safety.instance @signal_traps = {} @shutdown_hooks = [] end |
Instance Attribute Details
#load_paths ⇒ Object
List of load paths
249 250 251 |
# File 'lib/daemon_kit/initializer.rb', line 249 def load_paths @load_paths end |
#log_level ⇒ Object
The log level to use, defaults to DEBUG
255 256 257 |
# File 'lib/daemon_kit/initializer.rb', line 255 def log_level @log_level end |
#log_stdout ⇒ Object
Duplicate log data to stdout
261 262 263 |
# File 'lib/daemon_kit/initializer.rb', line 261 def log_stdout @log_stdout end |
#logger ⇒ Object
Custom logger instance to use
252 253 254 |
# File 'lib/daemon_kit/initializer.rb', line 252 def logger @logger end |
#pid_file ⇒ Object
Path to the pid file, defaults to ‘log/<daemon_name>.pid’
264 265 266 |
# File 'lib/daemon_kit/initializer.rb', line 264 def pid_file @pid_file end |
#root_path ⇒ Object (readonly)
Root to the daemon
246 247 248 |
# File 'lib/daemon_kit/initializer.rb', line 246 def root_path @root_path end |
#safety_net ⇒ Object
Our safety net (#Safety) instance
288 289 290 |
# File 'lib/daemon_kit/initializer.rb', line 288 def safety_net @safety_net end |
#shutdown_hooks ⇒ Object (readonly)
:nodoc: Shutdown hooks
291 292 293 |
# File 'lib/daemon_kit/initializer.rb', line 291 def shutdown_hooks @shutdown_hooks end |
#signal_traps ⇒ Object (readonly)
Collection of signal traps
285 286 287 |
# File 'lib/daemon_kit/initializer.rb', line 285 def signal_traps @signal_traps end |
Instance Method Details
#at_shutdown(proc = nil, &block) ⇒ Object
Add a block or proc to be called during shutdown
337 338 339 340 341 |
# File 'lib/daemon_kit/initializer.rb', line 337 def at_shutdown( proc = nil, &block ) return if proc.nil? && !block_given? @shutdown_hooks << ( proc || block ) end |
#daemon_initializer ⇒ Object
321 322 323 |
# File 'lib/daemon_kit/initializer.rb', line 321 def daemon_initializer "#{root_path}/config/initializers/#{self.daemon_name}.rb" end |
#environment ⇒ Object
311 312 313 |
# File 'lib/daemon_kit/initializer.rb', line 311 def environment ::DAEMON_ENV end |
#environment_path ⇒ Object
The path to the current environment’s file (development.rb
, etc.). By default the file is at config/environments/#{environment}.rb
.
317 318 319 |
# File 'lib/daemon_kit/initializer.rb', line 317 def environment_path "#{root_path}/config/environments/#{environment}.rb" end |
#trap(signal, proc = nil, &block) ⇒ Object
Add a trap for the specified signal, can be code block or a proc
326 327 328 329 330 331 332 333 334 |
# File 'lib/daemon_kit/initializer.rb', line 326 def trap( signal, proc = nil, &block ) return if proc.nil? && !block_given? unless @signal_traps.has_key?( signal ) set_trap( signal ) end @signal_traps[signal].unshift( proc || block ) end |