Sha256: e0273b115ec5b1ed05c9be9bd328f2afbc674bbc4c969b2fdb0bba8a4c8723dc
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require 'mizuno/server' require 'rack/builder' require_relative 'handler' require_relative 'api' require 'norikra/logger' include Norikra::Log module Norikra::WebUI class HTTP DEFAULT_LISTEN_HOST = '0.0.0.0' DEFAULT_LISTEN_PORT = 26578 # 26578 from 26571 and magic number 8 (for web) DEFAULT_THREADS = 2 attr_accessor :host, :port, :threads attr_accessor :engine, :mizuno, :thread def initialize(opts={}) @engine = opts[:engine] @host = opts[:host] || DEFAULT_LISTEN_HOST @port = opts[:port] || DEFAULT_LISTEN_PORT @threads = opts[:threads] || DEFAULT_THREADS Norikra::WebUI::Handler.engine = @engine Norikra::WebUI::API.engine = @engine @app = Rack::Builder.new { map '/api' do run Norikra::WebUI::API end run Norikra::WebUI::Handler } end def start info "WebUI server #{@host}:#{@port}, #{@threads} threads" @thread = Thread.new do @mizuno = Mizuno::Server.new @mizuno.run(@app, :embedded => true, :threads => @threads, :port => @port, :host => @host) end end def stop @mizuno.stop @thread.kill @thread.join end def shut_off(mode) Norikra::WebUI::Handler.shut_off = mode Norikra::WebUI::API.shut_off = mode end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
norikra-1.3.0.beta.1-java | lib/norikra/webui/http.rb |