Sha256: b971b574d40b62c8ea458f2d7f247c39b38d49133a90ebb495c0bb34887cf2f6
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 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 opts[:context_path] do map '/api' do run Norikra::WebUI::API end run Norikra::WebUI::Handler end } end def start info "WebUI server #{@host}:#{@port}, #{@threads} threads" @thread = Thread.new do @mizuno = Mizuno::Server.new options = { embedded: true, reuse_address: true, threads: @threads, min_threads: @threads, port: @port, host: @host } @mizuno.run(@app, options) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
norikra-1.5.1-java | lib/norikra/webui/http.rb |
norikra-1.5.0-java | lib/norikra/webui/http.rb |
norikra-1.4.0-java | lib/norikra/webui/http.rb |
norikra-1.3.1-java | lib/norikra/webui/http.rb |