Sha256: 8d776016baf4a4c97ab0c3369bc0efeab02878646a9aac4c4ae002cbec1cde7a

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# = Webrick AppServer
#
# Used temporarily unitl we build our own app server.
#
# code:: gmosx, elathan
#
# (c) 2004 Navel, all rights reserved.
# $Id: webrick.rb 71 2004-10-18 10:50:22Z gmosx $

require "drb"
require "cgi"
require "webrick"

require "n/logger"
require "n/application"
require "n/app/server"
require "n/app/webrick-servlet"

module N; module App

# = Webrick AppServer
#
# The Application Server. Handles dynamic requests in a web application.
# Dont keepalive (or use a VERY SMALL keepalive). Typically this server
# is used along with a standard http server that handles other resources.
#
class Webrick < N::Server
	include N::App::ServerMixin
	include WEBrick

	attr_accessor :webrick
	
	def initialize(name = "WebrickServer")
		super
		initialize_app()
	end

	def start
		accesslog = WEBrick::BasicLog::new("/dev/null") 
		referer = WEBrick::BasicLog::new("/dev/null")	
		
		@webrick = HTTPServer.new(
			:BindAddress => $appsrv_address, 
			:Port => $appsrv_port, 
			:DirectoryIndex => ["index.sx"],
			# gmosx, FIXME: this shit still logs!!
			:Logger => Log.new(nil, WEBrick::Log::WARN),
			# elathan: amateur...
			:AccessLog => [
          [accesslog, AccessLog::COMMON_LOG_FORMAT],
          [referer, AccessLog::REFERER_LOG_FORMAT]
        ]
		)
		
		@webrick.mount("/", N::App::WebrickServlet)
		
		trap("INT") {
		 @webrick.shutdown() 
		}
		
		@webrick.start()
	end
	
	def stop
		@webrick.stop
	end
	
end

end; end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.1.2 lib/n/app/webrick.rb