Module: Hoss::Sinatra

Extended by:
Sinatra
Included in:
Sinatra
Defined in:
lib/hoss/sinatra.rb

Overview

Module for starting the Hoss agent and hooking into Sinatra.

Instance Method Summary collapse

Instance Method Details

#start(app, config = {}) ⇒ true?

Start the Hoss agent and hook into Sinatra.

Parameters:

  • app (Sinatra::Base)

    A Sinatra app.

  • config (Config, Hash) (defaults to: {})

    An instance of Config or a Hash config.

Returns:

  • (true, nil)

    true if the agent was started, nil otherwise.



29
30
31
32
33
34
35
36
37
38
# File 'lib/hoss/sinatra.rb', line 29

def start(app, config = {})
  config = Config.new(config) unless config.is_a?(Config)
  configure_app(app, config)

  Hoss.start(config)
  Hoss.running?
rescue StandardError => e
  config.logger.error format('Failed to start: %s', e.message)
  config.logger.debug "Backtrace:\n" + e.backtrace.join("\n")
end