Class: Puma::Single
Overview
This class is instantiated by the ‘Puma::Launcher` and used to boot and serve a Ruby application when no puma “workers” are needed i.e. only using “threaded” mode. For example `$ puma -t 1:5`
At the core of this class is running an instance of ‘Puma::Server` which gets created via the `start_server` method from the `Puma::Runner` class that this inherits from.
Instance Attribute Summary collapse
Attributes inherited from Runner
#app, #options, #ruby_engine
Instance Method Summary
collapse
Methods inherited from Runner
#close_control_listeners, #debug, #development?, #error, #initialize, #load_and_bind, #log, #output_header, #redirect_io, #redirected_io?, #start_control, #start_server, #stop_control, #test?, #wakeup!
Constructor Details
This class inherits a constructor from Puma::Runner
Instance Attribute Details
#stats ⇒ Object
17
18
19
20
21
|
# File 'lib/puma/single.rb', line 17
def stats
{
started_at: utc_iso8601(@started_at)
}.merge(@server.stats).merge(super)
end
|
Instance Method Details
#halt ⇒ Object
31
32
33
|
# File 'lib/puma/single.rb', line 31
def halt
@server&.halt
end
|
#restart ⇒ Object
23
24
25
|
# File 'lib/puma/single.rb', line 23
def restart
@server&.begin_restart
end
|
#run ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/puma/single.rb', line 41
def run
"single"
load_and_bind
Plugins.fire_background
@launcher.write_state
start_control
@server = server = start_server
server_thread = server.run
log "Use Ctrl-C to stop"
redirect_io
@events.fire_on_booted!
debug_loaded_extensions("Loaded Extensions:") if @log_writer.debug?
begin
server_thread.join
rescue Interrupt
end
end
|
#stop ⇒ Object
27
28
29
|
# File 'lib/puma/single.rb', line 27
def stop
@server&.stop false
end
|
#stop_blocked ⇒ Object
35
36
37
38
39
|
# File 'lib/puma/single.rb', line 35
def stop_blocked
log "- Gracefully stopping, waiting for requests to finish"
@control&.stop true
@server&.stop true
end
|