19
20
21
22
23
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
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rubylet/jetty.rb', line 19
def run(app, options)
@server = Server.new
connector = SelectChannelConnector.new
connector.setPort options[:Port].to_i
connector.setHost options[:Host]
@server.addConnector connector
if options[:Threads]
pool = ExecutorThreadPool.new(options[:Threads].to_i,
options[:Threads].to_i,
0)
@server.setThreadPool pool
end
context = ServletContextHandler.new(ServletContextHandler::SESSIONS)
context.setContextPath('/')
ServletHolder.new(Rubylet::Servlet.new).tap do |holder|
holder.setInitParameter 'jrubyHome', jruby_home
holder.setInitParameter 'appRoot', File.dirname(options[:config])
holder.setInitParameter 'rackupFile', options[:config]
context.addServlet holder, '/*'
end
if options[:StaticUrls]
ServletHolder.new(DefaultServlet.new).tap do |holder|
{
'acceptRanges' => true,
'welcomeServlets' => false,
'gzip' => true,
'resourceBase' => options[:StaticRoot] || 'public'
}.each { |k,v| holder.setInitParameter(k, v.to_s) }
options[:StaticUrls].split(',').each do |prefix|
prefix = "/#{prefix}" unless prefix.start_with? '/'
context.addServlet holder, "#{prefix}/*"
end
end
end
@server.setHandler(context)
@server.start
@server.join
end
|