Class: N::App::Webrick

Inherits:
Server show all
Includes:
ServerMixin, WEBrick
Defined in:
lib/n/app/webrick.rb

Overview

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.

Instance Attribute Summary collapse

Attributes inherited from Server

#address, #port

Attributes inherited from N::Application

#create_time, #daemonized, #description, #name, #pid, #pidfile, #status, #title, #version

Instance Method Summary collapse

Methods included from ServerMixin

#initialize_app

Methods inherited from Server

#handle, #run

Methods inherited from N::Application

#daemon_pid, #daemonize, #parse_arguments, #restart, #run

Constructor Details

#initialize(name = "WebrickServer") ⇒ Webrick

Returns a new instance of Webrick.



33
34
35
36
# File 'lib/n/app/webrick.rb', line 33

def initialize(name = "WebrickServer")
	super
	initialize_app()
end

Instance Attribute Details

#webrickObject

Returns the value of attribute webrick.



31
32
33
# File 'lib/n/app/webrick.rb', line 31

def webrick
  @webrick
end

Instance Method Details

#startObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/n/app/webrick.rb', line 38

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

#stopObject



64
65
66
# File 'lib/n/app/webrick.rb', line 64

def stop
	@webrick.stop
end