lib/bmc-daemon-lib/conf.rb in bmc-daemon-lib-0.3.6 vs lib/bmc-daemon-lib/conf.rb in bmc-daemon-lib-0.3.8

- old
+ new

@@ -77,12 +77,12 @@ # Set up encodings Encoding.default_internal = "utf-8" Encoding.default_external = "utf-8" # Init New Relic, Rollbar - prepare_newrelic if self.feature?(:newrelic) - prepare_rollbar if self.feature?(:rollbar) + # prepare_newrelic + #prepare_rollbar if self.feature?(:rollbar) # Try to access any key to force parsing of the files self[:dummy] rescue Psych::SyntaxError => e @@ -130,16 +130,17 @@ ensure_init # Guess if the specific feature si available case name when :newrelic - self.at(:newrelic, :license) + return false if Gem.datadir('newrelic_rpm').nil? + return self.at(:newrelic, :license) when :rollbar - self.at(:rollbar, :token) - else - false + return false if Gem.datadir('rollbar').nil? + return self.at(:rollbar, :token) end + return false end # Defaults generators def self.generate what ensure_init @@ -169,23 +170,13 @@ "A default configuration is available (#{config_defaults}) and can be copied to the default location (#{config_etc}): \n sudo cp #{config_defaults} #{config_etc}" end end - - protected - - def self.load_files - load files: @files, namespaces: { environment: @app_env } - end - - def self.add_config path - @files << File.expand_path(path) if path && File.readable?(path) - end - def self.prepare_newrelic - # Require lib + # Disable if no config present + return unless self.feature?(:newrelic) section = self[:newrelic] # Enable GC profiler GC::Profiler.enable @@ -208,33 +199,36 @@ # Enable module ENV["NEWRELIC_AGENT_ENABLED"] = "true" end def self.prepare_rollbar - # # Disable if no config present - # return unless self.feature?(:rollbar) + # Disable if no config present + return unless self.feature?(:rollbar) section = self[:rollbar] # Configure Rollbar.configure do |config| config.enabled = true config.access_token = section[:token].to_s config.code_version = @app_version - - #config.logger - config.environment = @app_env - - # Report asynchronously + config.environment = @app_env + #config.logger = Logger.new(logfile_path(:rollbar)) + config.logger = LoggerPool.instance.get :rollbar config.use_async = true - # Here we'll disable in 'test': - # if Rails.env.test? || Rails.env.development? - # config.enabled = false - # end - #logfile_path(:newrelic) end # Notify startup Rollbar.info("#{@app_name} #{@app_ver} [#{@host}]") + end + + protected + + def self.load_files + load files: @files, namespaces: { environment: @app_env } + end + + def self.add_config path + @files << File.expand_path(path) if path && File.readable?(path) end private def self.ensure_init