Module: Nezu::Runtime
- Defined in:
- lib/nezu/runtime.rb,
lib/nezu/runtime/worker.rb,
lib/nezu/runtime/consumer.rb,
lib/nezu/runtime/producer.rb,
lib/nezu/runtime/recipient.rb
Defined Under Namespace
Modules: Common Classes: Consumer, Producer, Recipient, RecipientError, Worker
Class Method Summary collapse
-
.load_config ⇒ Object
load everything needed to run the app.
Class Method Details
.load_config ⇒ Object
load everything needed to run the app
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 |
# File 'lib/nezu/runtime.rb', line 8 def self.load_config configure_from_yaml('database.yml') begin configure_from_yaml('amqp.yml') rescue Nezu.logger.fatal("[Nezu Runner] no amqp config please create one in config/amqp.yml") unless Nezu::Config.amqp.present? raise end if Nezu::Config.database.send(Nezu.env).database.present? && !Class.const_defined?(:Rails) require Nezu::Config.database.send(Nezu.env).adapter ActiveRecord::Base.establish_connection(Nezu::Config.database.send(Nezu.env.to_sym).to_hash) ActiveRecord::Base.logger = Logger.new(Nezu.root.join('log/', 'database.log')) end req_files = Dir.glob(Nezu.root.join('app', 'consumers', '*.rb')) req_files += Dir.glob(Nezu.root.join('app', 'producers', '*.rb')) unless Class.const_defined?(:Rails) req_files += Dir.glob(Nezu.root.join('app', 'models', '*.rb')) req_files += Dir.glob(Nezu.root.join('lib', '**', '*.rb')) end req_files.each do |file_name| Nezu.logger.debug("requiring #{file_name}") require file_name #Autoload is not thread-safe :( end app_config=Nezu.root.join('config', 'nezu.rb') if File.exist?(app_config) require app_config else Nezu.logger.info("#{app_config} doesn`t exist. I`m skipping it") end Nezu.logger.debug("[Nezu Runner] config loaded") Nezu.logger.debug(Nezu::Config.amqp) end |