Module: TP2
- Defined in:
- lib/tp2.rb,
lib/tp2/logger.rb,
lib/tp2/server.rb,
lib/tp2/version.rb,
lib/tp2/rack_adapter.rb,
lib/tp2/http1_adapter.rb
Defined Under Namespace
Modules: RackAdapter
Classes: HTTP1Adapter, Logger, Server
Constant Summary
collapse
- BANNER =
(
"\n" +
" ooo\n" +
" oo\n" +
" o\n" +
" \\|/ TP2 - a modern web server for Ruby apps\n" +
" / \\ \n" +
" / \\ https://github.com/noteflakes/tp2\n" +
"⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺\n"
)
- VERSION =
'0.10'
Class Method Summary
collapse
Class Method Details
.config(opts = nil, &app) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/tp2.rb', line 51
def config(opts = nil, &app)
return @config if !opts && !app
@config = opts || {}
@config[:app] = app if app
end
|
.run(opts = nil, &app) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/tp2.rb', line 27
def run(opts = nil, &app)
if @in_run
@config = opts if opts
@config[:app] = app if app
return
end
opts ||= @config || {}
begin
@in_run = true
machine = UM.new
machine.puts(TP2::BANNER) if opts[:banner]
opts[:log] = opts[:log] && TP2::Logger.new(machine, **opts)
server = Server.new(machine, opts, &app)
setup_signal_handling(machine, Fiber.current)
server.run
ensure
@in_run = false
end
end
|