Class: DaemonKit::Configuration
- Inherits:
-
Object
- Object
- DaemonKit::Configuration
- Defined in:
- lib/daemon_kit/initializer.rb
Overview
Holds our various configuration values
Instance Attribute Summary collapse
-
#daemon_name ⇒ Object
The application name.
-
#dir ⇒ Object
Path to the log file, defaults to ‘log/<environment>.log’.
-
#dir_mode ⇒ Object
:system,.
-
#force_kill_wait ⇒ Object
Use the force kill patch? Give the number of seconds.
-
#load_paths ⇒ Object
List of load paths.
-
#log_level ⇒ Object
The log level to use, defaults to DEBUG.
-
#log_path ⇒ Object
Path to the log file, defaults to ‘log/<environment>.log’.
-
#logger ⇒ Object
Provide a custom logger to use.
-
#multiple ⇒ Object
Allow multiple copies to run?.
-
#root_path ⇒ Object
readonly
Root to the daemon.
-
#signal_traps ⇒ Object
readonly
Collection of signal traps.
Instance Method Summary collapse
- #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.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/daemon_kit/initializer.rb', line 169 def initialize set_root_path! self.load_paths = default_load_paths self.log_level = default_log_level self.log_path = default_log_path self.multiple = false self.force_kill_wait = false @signal_traps = {} end |
Instance Attribute Details
#daemon_name ⇒ Object
The application name
158 159 160 |
# File 'lib/daemon_kit/initializer.rb', line 158 def daemon_name @daemon_name end |
#dir ⇒ Object
Path to the log file, defaults to ‘log/<environment>.log’
152 153 154 |
# File 'lib/daemon_kit/initializer.rb', line 152 def dir @dir end |
#dir_mode ⇒ Object
:system,
149 150 151 |
# File 'lib/daemon_kit/initializer.rb', line 149 def dir_mode @dir_mode end |
#force_kill_wait ⇒ Object
Use the force kill patch? Give the number of seconds
164 165 166 |
# File 'lib/daemon_kit/initializer.rb', line 164 def force_kill_wait @force_kill_wait end |
#load_paths ⇒ Object
List of load paths
140 141 142 |
# File 'lib/daemon_kit/initializer.rb', line 140 def load_paths @load_paths end |
#log_level ⇒ Object
The log level to use, defaults to DEBUG
143 144 145 |
# File 'lib/daemon_kit/initializer.rb', line 143 def log_level @log_level end |
#log_path ⇒ Object
Path to the log file, defaults to ‘log/<environment>.log’
146 147 148 |
# File 'lib/daemon_kit/initializer.rb', line 146 def log_path @log_path end |
#logger ⇒ Object
Provide a custom logger to use
155 156 157 |
# File 'lib/daemon_kit/initializer.rb', line 155 def logger @logger end |
#multiple ⇒ Object
Allow multiple copies to run?
161 162 163 |
# File 'lib/daemon_kit/initializer.rb', line 161 def multiple @multiple end |
#root_path ⇒ Object (readonly)
Root to the daemon
137 138 139 |
# File 'lib/daemon_kit/initializer.rb', line 137 def root_path @root_path end |
#signal_traps ⇒ Object (readonly)
Collection of signal traps
167 168 169 |
# File 'lib/daemon_kit/initializer.rb', line 167 def signal_traps @signal_traps end |
Instance Method Details
#daemon_initializer ⇒ Object
192 193 194 |
# File 'lib/daemon_kit/initializer.rb', line 192 def daemon_initializer "#{root_path}/config/initializers/#{self.daemon_name}.rb" end |
#environment ⇒ Object
182 183 184 |
# File 'lib/daemon_kit/initializer.rb', line 182 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
.
188 189 190 |
# File 'lib/daemon_kit/initializer.rb', line 188 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
197 198 199 200 201 202 203 204 205 |
# File 'lib/daemon_kit/initializer.rb', line 197 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 |