Sha256: 3650b408b243b2fa9396fccfff39915b1424b95d75298c31ac0990cb5026478c

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

require 'logger'

module Midori
  @logger = ::Logger.new(StringIO.new)

  def self.run(api = Midori::API, ip = nil, port = nil, logger = ::Logger.new(STDOUT))
    ip ||= '127.0.0.1'
    port ||= 8081
    @logger = logger
    EventMachine.run do
      @logger.info "Midori #{Midori::VERSION} is now running on #{ip}:#{port}".blue
      @midori_server = EventMachine.start_server ip, port, Midori::Server, api, logger
    end
  end

  def self.stop
    if @midori_server.nil?
      @logger.error 'Midori Server has NOT been started'.red
      return false
    else
      EventMachine.stop_server(@midori_server)
      @midori_server = nil
      @logger.info 'Goodbye Midori'.blue
      return true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-midori-0.0.9.2 lib/em-midori/em_midori.rb