Sha256: 60d64cfa79588317352cf020b2d28fb5f777b31b66594dc4b6d3120e6fc1a218
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
require 'webrick' require 'webrick/https' require 'openssl' class KL::Server def initialize @config = KL.config if @config['api']['ssl'] options = { :Port => @config['api']['port'], :SSLEnable => true, :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, :SSLCertificate => OpenSSL::X509::Certificate.new(File.open(@config['api']['cert']['crt']).read), :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open(@config['api']['cert']['key']).read), :SSLCertName => [[ "CN", WEBrick::Utils::getservername ]] } else options = { :Port => @config['api']['port'], :SSLEnable => false } end @webrick_options = options @server = ::Rack::Handler::WEBrick end def start KL.logger.info '[server] Starting web server...' Thread.new { @server.run KL::Api, @webrick_options } if (@config['api']['ssl']) msg = "[server] Web server listening on #{@config['api']['port']} with SSL" else msg = "[server] Web server listening on #{@config['api']['port']}" end KL.logger.info msg end def stop @server.shutdown KL.logger.info '[server] Web server has stopped.' end end
Version data entries
9 entries across 9 versions & 1 rubygems