class OktaAuthProxy::ProxyServer

Public Class Methods

new(port: 3311, threads:1000, bind: '127.0.0.1', debug:false) click to toggle source
# File lib/okta-auth-proxy/server.rb, line 7
def initialize(port: 3311, threads:1000, bind: '127.0.0.1', debug:false)
  debug ||= ENV['DEBUG']

  if debug
    $stdout.sync = true
    $stderr.sync = true
  end

  app = ProxyApp.new
  dispatch = Rack::Builder.app do
    map '/' do
      run app
    end
  end
  @server = Thin::Server.new(port, bind, dispatch, threadpool_size: threads).backend
end

Public Instance Methods

run() click to toggle source
# File lib/okta-auth-proxy/server.rb, line 28
def run
  EM.run do
    init_sighandlers
    @server.start
  end
end
start() click to toggle source
# File lib/okta-auth-proxy/server.rb, line 24
def start
  @server.start
end

Private Instance Methods

init_sighandlers() click to toggle source
# File lib/okta-auth-proxy/server.rb, line 36
def init_sighandlers
  trap(:INT)  { 'Got interrupt'; EM.stop; exit }
  trap(:TERM) { 'Got term';      EM.stop; exit }
  trap(:KILL) { 'Got kill';      EM.stop; exit }
end