Sha256: 0d8c910c28a95a9656ed8251a4b435c21ff0349ddf6cbe00a995e2eb64e6e2f7
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
## # Abstract runner class to control instance of Midori Server class Midori::Runner attr_reader :bind, :port def initialize(api, configure = Midori::Configure) @logger = configure.logger @bind = configure.bind @port = configure.port @api = api end # Get Midori server whether running # @return [Boolean] [true] running # @return [Boolean] [false] not running def running? !!@server_signature end # Start the Midori server # @note This is an async method, but no callback def start return if running? EventMachine.set_simultaneous_accept_count(40) unless RUBY_PLATFORM == 'java' EventMachine.run do @logger.info "Midori #{Midori::VERSION} is now running on #{bind}:#{port}".blue @server_signature = EventMachine.start_server bind, port, Midori::Server, @api, @logger end nil end # Stop the Midori server # @note This is an async method, but no callback # @return [Boolean] [true] stop successfully # @return [Boolean] [false] nothing to stop def stop if running? @logger.info 'Goodbye Midori'.blue EventMachine.stop_server(@server_signature) @server_signature = nil EM.stop true else @logger.error 'Midori Server has NOT been started'.red false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
em-midori-0.1.0 | lib/em-midori/runner.rb |