class MotherBrain::RestGateway
Constants
- DEFAULT_OPTIONS
- DEFAULT_PORT
- VALID_OPTIONS
Public Class Methods
instance()
click to toggle source
@raise [Celluloid::DeadActorError] if rest gateway has not been started
@return [Celluloid::Actor(Gateway)]
# File lib/mb/rest_gateway.rb, line 9 def instance MB::Application[:rest_gateway] or raise Celluloid::DeadActorError, "REST Gateway not running" end
new(options = {})
click to toggle source
@option options [String] :host (‘0.0.0.0’) @option options [Integer] :port (26100) @option options [Boolean] :quiet (false)
Calls superclass method
# File lib/mb/rest_gateway.rb, line 51 def initialize(options = {}) log.debug { "REST Gateway starting..." } options = DEFAULT_OPTIONS.merge(options.slice(*VALID_OPTIONS)) app = MB::API::Application.new # reel-rack uses Rack standard capitalizations in > 0.0.2 options[:Host] = options[:host] options[:Port] = options[:port] log.info { "REST Gateway listening on #{options[:host]}:#{options[:port]}" } begin super(app, options) rescue Errno::EADDRINUSE log.fatal { "Port #{options[:port]} is already in use. Unable to start rest gateway." } end end
start(options = {})
click to toggle source
Start the REST Gateway and add it to the application’s registry.
@note you probably don’t want to manually start the REST Gateway unless you are testing. Start
the entire application with {MB::Application.run}
# File lib/mb/rest_gateway.rb, line 17 def start(options = {}) MB::Application[:rest_gateway] = new(options) end
stop()
click to toggle source
Stop the currently running REST Gateway
@note you probably don’t want to manually stop the REST Gateway unless you are testing. Stop
the entire application with {MB::Application.stop}
# File lib/mb/rest_gateway.rb, line 25 def stop instance.shutdown end
Private Instance Methods
finalize_callback()
click to toggle source
# File lib/mb/rest_gateway.rb, line 72 def finalize_callback log.debug { "REST Gateway stopping..." } self.shutdown end