Class: Puma::Single
Instance Method Summary
collapse
Methods inherited from Runner
#app, #before_restart, #daemon?, #development?, #error, #initialize, #load_and_bind, #log, #output_header, #redirect_io, #start_control, #start_server
Constructor Details
This class inherits a constructor from Puma::Runner
Instance Method Details
#halt ⇒ Object
19
20
21
|
# File 'lib/puma/single.rb', line 19
def halt
@server.halt
end
|
#jruby_daemon? ⇒ Boolean
29
30
31
|
# File 'lib/puma/single.rb', line 29
def jruby_daemon?
daemon? and @cli.jruby?
end
|
#restart ⇒ Object
11
12
13
|
# File 'lib/puma/single.rb', line 11
def restart
@server.begin_restart
end
|
#run ⇒ Object
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/puma/single.rb', line 33
def run
already_daemon = false
if jruby_daemon?
require 'puma/jruby_restart'
if JRubyRestart.daemon?
load_and_bind
end
already_daemon = JRubyRestart.daemon_init
end
"single"
if jruby_daemon?
if already_daemon
JRubyRestart.perm_daemonize
else
pid = nil
Signal.trap "SIGUSR2" do
log "* Started new process #{pid} as daemon..."
exit!(true)
end
Signal.trap "SIGCHLD" do
log "! Error starting new process as daemon, exitting"
exit 1
end
pid = @cli.jruby_daemon_start
sleep
end
else
load_and_bind
if daemon?
log "* Daemonizing..."
Process.daemon(true)
end
end
@cli.write_state
start_control
@server = server = start_server
unless @options[:daemon]
log "Use Ctrl-C to stop"
end
redirect_io
@cli.events.fire_on_booted!
begin
server.run.join
rescue Interrupt
end
end
|
#stats ⇒ Object
5
6
7
8
9
|
# File 'lib/puma/single.rb', line 5
def stats
b = @server.backlog
r = @server.running
%Q!{ "backlog": #{b}, "running": #{r} }!
end
|
#stop ⇒ Object
15
16
17
|
# File 'lib/puma/single.rb', line 15
def stop
@server.stop false
end
|
#stop_blocked ⇒ Object
23
24
25
26
27
|
# File 'lib/puma/single.rb', line 23
def stop_blocked
log "- Gracefully stopping, waiting for requests to finish"
@control.stop(true) if @control
@server.stop(true)
end
|