Method: OmfCommon.init
- Defined in:
- lib/omf_common.rb
.init(op_mode, opts = {}, &block) ⇒ Object
Initialise the OMF runtime.
The options here can be customised via EC or RC’s configuration files.
Given the following example EC configuration file (YAML format):
environment: development
communication:
url: amqp://localhost
OMF runtime will be configured as:
OmfCommon.init(:development, { communication: { url: "amqp://localhost" }})
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/omf_common.rb', line 188 def self.init(op_mode, opts = {}, &block) opts = _rec_sym_keys(opts) if op_mode && defs = DEFAULTS[op_mode.to_sym] opts = _rec_merge(defs, opts) end if dopts = opts.delete(:daemonize) dopts[:app_name] ||= "#{File.basename($0, File.extname($0))}_daemon" require 'daemons' Daemons.run_proc(dopts[:app_name], dopts) do init(nil, opts, &block) end return end if lopts = opts[:logging] _init_logging(lopts) unless lopts.empty? end unless copts = opts[:communication] raise "Missing :communication description" end if aopts = opts[:auth] require 'omf_common/auth/credential_store' OmfCommon::Auth::CredentialStore.init(aopts) end # Initialise event loop eopts = opts[:eventloop] Eventloop.init(eopts) # start eventloop immediately if we received a run block eventloop.run do Comm.init(copts) block.call(eventloop) if block end end |