Sha256: 98af2335b82ec968c720d9d55f4c6beb37feb7b25820c72f9b46f8f35aad69b6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'sinatra/base'
require 'webrick'
require 'webrick/https'
require 'openssl'

require 'arnold/server'

module Arnold
  module Controller
    class Web
      def initialize
        opts = {
                :Port               => $CONFIG[:port] || 8080,
                :Logger             => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG),
                :ServerType         => $CONFIG[:daemonize] ? WEBrick::Daemon : WEBrick::SimpleServer,
                :DocumentRoot       => $CONFIG[:docroot],
                :SSLEnable          => true,
                :SSLVerifyClient    => OpenSSL::SSL::VERIFY_NONE,
                :SSLCertificate     => OpenSSL::X509::Certificate.new(  File.open($CONFIG[:sslcert]).read),
                :SSLPrivateKey      => OpenSSL::PKey::RSA.new(          File.open($CONFIG[:sslkey]).read),
                :SSLCertName        => [ [ "CN",WEBrick::Utils::getservername ] ]
        }

        # now it's off to the races!
        Rack::Handler::WEBrick.run(Arnold::Server, opts) do |server|
          [:INT, :TERM].each { |sig| trap(sig) { server.stop } }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arnold-0.0.1 lib/arnold/controller/web.rb