Create an instance of the Sensu API process, setup the Redis and Transport connections, start the API HTTP server, set up API process signal traps (for stopping), within the EventMachine event loop.
@param options [Hash]
# File lib/sensu/api/process.rb, line 15 def self.run(options={}) api = self.new(options) EM::run do api.setup_redis api.setup_transport api.start api.setup_signal_traps end end
Start the Sensu API HTTP server. This method sets the service state to `:running`.
# File lib/sensu/api/process.rb, line 45 def start api = @settings[:api] || {} bind = api[:bind] || "0.0.0.0" port = api[:port] || 4567 start_http_server(bind, port) super end
Start the API HTTP server. This method sets `@http_server`.
@param bind [String] address to listen on. @param port [Integer] to listen on.
# File lib/sensu/api/process.rb, line 29 def start_http_server(bind, port) @logger.info("api listening", { :protocol => "http", :bind => bind, :port => port }) @http_server = EM::start_server(bind, port, HTTPHandler) do |handler| handler.logger = @logger handler.settings = @settings handler.redis = @redis handler.transport = @transport end end
Stop the Sensu API process. This method stops the HTTP server, closes the Redis and transport connections, sets the service state to `:stopped`, and stops the EventMachine event loop.
# File lib/sensu/api/process.rb, line 56 def stop @logger.warn("stopping") EM::stop_server(@http_server) @redis.close if @redis @transport.close if @transport super end