Class: Rascut::Httpd
- Inherits:
-
Object
show all
- Includes:
- Utils
- Defined in:
- lib/rascut/httpd.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Utils
asdoc_home, home, path_escape, rascut_db, rascut_db_path, rascut_db_read
Constructor Details
#initialize(command) ⇒ Httpd
Returns a new instance of Httpd.
17
18
19
20
21
|
# File 'lib/rascut/httpd.rb', line 17
def initialize(command)
@command = command
@http_servet =
@threads = []
end
|
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
22
23
24
|
# File 'lib/rascut/httpd.rb', line 22
def command
@command
end
|
Instance Method Details
#config ⇒ Object
60
61
62
|
# File 'lib/rascut/httpd.rb', line 60
def config
command.config
end
|
#logger ⇒ Object
64
65
66
|
# File 'lib/rascut/httpd.rb', line 64
def logger
config.logger
end
|
#reload! ⇒ Object
68
69
70
71
72
|
# File 'lib/rascut/httpd.rb', line 68
def reload!
while t = @threads.pop
t.run
end
end
|
#run ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rascut/httpd.rb', line 24
def run
swf_path = command.root.to_s
logger.debug "swf_path: #{swf_path}"
vendor = Pathname.new(__FILE__).parent.parent.parent.join('vendor')
logger.debug "vendor_path: #{vendor}"
file_mappings = [
['/js/swfobject.js', vendor.join('js/swfobject.js').to_s],
['/swf', swf_path]
]
file_mappings.concat(config_url_mapping) if config[:mapping]
logger.debug 'url mappings: ' + file_mappings.inspect
port = config[:port] || 3001
host = config[:bind_address] || '0.0.0.0'
reload = reload_handler
index = index_handler
@http_server = Mongrel::HttpServer.new(host, port)
file_mappings.each do |mapping|
@http_server.register(mapping[0], Mongrel::DirHandler.new(mapping[1]))
end
@http_server.register('/proxy', proxy_handler)
@http_server.register('/save', save_handler)
@http_server.register('/reload', reload_handler)
@http_server.register('/', index_handler)
@http_server.run
logger.info "Start Mongrel: http://#{host}:#{port}/"
end
|
#stop ⇒ Object
55
56
57
58
|
# File 'lib/rascut/httpd.rb', line 55
def stop
end
|