Module: D13n::Service::Start
- Included in:
- D13n::Service
- Defined in:
- lib/d13n/service/start.rb
Instance Method Summary collapse
- #config_server_raise_on_failure? ⇒ Boolean
- #log_environment ⇒ Object
- #log_service_name ⇒ Object
- #log_startup ⇒ Object
- #log_version_and_pid ⇒ Object
- #query_server_for_configuration ⇒ Object
- #start_api_service ⇒ Object
- #start_metric_manager ⇒ Object
Instance Method Details
#config_server_raise_on_failure? ⇒ Boolean
63 64 65 |
# File 'lib/d13n/service/start.rb', line 63 def config_server_raise_on_failure? D13n.config[:'config_server.raise_on_failure'] == true || D13n.config[:'config_server.raise_on_failure'] == 'true' end |
#log_environment ⇒ Object
25 26 27 |
# File 'lib/d13n/service/start.rb', line 25 def log_environment D13n.logger.info "Environment: #{D13n.service.instance.env}" end |
#log_service_name ⇒ Object
29 30 31 |
# File 'lib/d13n/service/start.rb', line 29 def log_service_name D13n.logger.info "Service: #{D13n.config.app_name}" end |
#log_startup ⇒ Object
20 21 22 23 |
# File 'lib/d13n/service/start.rb', line 20 def log_startup log_environment log_service_name end |
#log_version_and_pid ⇒ Object
33 34 35 |
# File 'lib/d13n/service/start.rb', line 33 def log_version_and_pid D13n.logger.debug "#{D13n.config.app_name} Service #{D13n.service.app_class::VERSION}(D13n:#{D13n::VERSION::STRING}) Initialized: pid = #{$$}" end |
#query_server_for_configuration ⇒ Object
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 |
# File 'lib/d13n/service/start.rb', line 37 def query_server_for_configuration begin # # TODO: Config Kit may enhance configurator # ConfigKit.config.url = D13n.config[:ck_url] || D13n.config[:'service.config_kit.url'] config_data = ConfigKit::Manager.get(D13n.config.app_name) rescue ConfigKit::Client::ConfigKitReadError => e D13n.logger.error "Config Kit reads server error. #{e.message}" raise ServiceStartError.new(e.) if config_server_raise_on_failure? rescue Exception => e D13n.logger.error "Unknown Config Kit error. #{e.message}" D13n.logger.debug e raise ServiceStartError.new(e.) if config_server_raise_on_failure? end # # TODO: Empty to raise exception # return if config_data.nil? || config_data.empty? D13n.logger.debug "Server provided config: #{config_data.inspect}" server_config = D13n::Configuration::ServerSource.build(config_data) D13n.config.replace_or_add_config(server_config) end |
#start_api_service ⇒ Object
15 16 17 18 |
# File 'lib/d13n/service/start.rb', line 15 def start_api_service @started = true Object.const_get("#{D13n.application.name}::Api::Service").run!(@service_conf) end |
#start_metric_manager ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/d13n/service/start.rb', line 6 def start_metric_manager begin channel = determine_metric_channel Metric::Manager.start(channel) rescue Exception => e D13n.logger.error "Unknown Instrument Manager error. #{e.message}" end end |