1Mojo::Server::HypnotoadU(s3e)r Contributed Perl DocumentaMtoijoon::Server::Hypnotoad(3)
2
3
4

NAME

6       Mojo::Server::Hypnotoad - A production web serv...ALL GLORY TO THE
7       HYPNOTOAD!
8

SYNOPSIS

10         use Mojo::Server::Hypnotoad;
11
12         my $hypnotoad = Mojo::Server::Hypnotoad->new;
13         $hypnotoad->run('/home/sri/myapp.pl');
14

DESCRIPTION

16       Mojo::Server::Hypnotoad is a full featured, UNIX optimized, pre-forking
17       non-blocking I/O HTTP and WebSocket server, built around the very well
18       tested and reliable Mojo::Server::Prefork, with IPv6, TLS, SNI, UNIX
19       domain socket, Comet (long polling), keep-alive, multiple event loop
20       and hot deployment support that just works. Note that the server uses
21       signals for process management, so you should avoid modifying signal
22       handlers in your applications.
23
24       To start applications with it you can use the hypnotoad script, which
25       listens on port 8080, automatically daemonizes the server process and
26       defaults to "production" mode for Mojolicious and Mojolicious::Lite
27       applications.
28
29         $ hypnotoad ./myapp.pl
30
31       You can run the same command again for automatic hot deployment.
32
33         $ hypnotoad ./myapp.pl
34         Starting hot deployment for Hypnotoad server 31841.
35
36       This second invocation will load the application again, detect the
37       process id file with it, and send a "USR2" signal to the already
38       running server.
39
40       For better scalability (epoll, kqueue) and to provide non-blocking name
41       resolution, SOCKS5 as well as TLS support, the optional modules EV
42       (4.32+), Net::DNS::Native (0.15+), IO::Socket::Socks (0.64+) and
43       IO::Socket::SSL (2.009+) will be used automatically if possible.
44       Individual features can also be disabled with the "MOJO_NO_NNR",
45       "MOJO_NO_SOCKS" and "MOJO_NO_TLS" environment variables.
46
47       See "DEPLOYMENT" in Mojolicious::Guides::Cookbook for more.
48

MANAGER SIGNALS

50       The Mojo::Server::Hypnotoad manager process can be controlled at
51       runtime with the following signals.
52
53   INT, TERM
54       Shut down server immediately.
55
56   QUIT
57       Shut down server gracefully.
58
59   TTIN
60       Increase worker pool by one.
61
62   TTOU
63       Decrease worker pool by one.
64
65   USR2
66       Attempt zero downtime software upgrade (hot deployment) without losing
67       any incoming connections.
68
69         Manager (old)
70         |- Worker [1]
71         |- Worker [2]
72         |- Worker [3]
73         |- Worker [4]
74         +- Manager (new)
75            |- Worker [1]
76            |- Worker [2]
77            |- Worker [3]
78            +- Worker [4]
79
80       The new manager will automatically send a "QUIT" signal to the old
81       manager and take over serving requests after starting up successfully.
82

WORKER SIGNALS

84       Mojo::Server::Hypnotoad worker processes can be controlled at runtime
85       with the following signals.
86
87   QUIT
88       Stop worker gracefully.
89

SETTINGS

91       Mojo::Server::Hypnotoad can be configured with the following settings,
92       see "Hypnotoad" in Mojolicious::Guides::Cookbook for examples.
93
94   accepts
95         accepts => 100
96
97       Maximum number of connections a worker is allowed to accept, before
98       stopping gracefully and then getting replaced with a newly started
99       worker, defaults to the value of "accepts" in Mojo::Server::Prefork.
100       Setting the value to 0 will allow workers to accept new connections
101       indefinitely. Note that up to half of this value can be subtracted
102       randomly to improve load balancing, and to make sure that not all
103       workers restart at the same time.
104
105   backlog
106         backlog => 128
107
108       Listen backlog size, defaults to the value of "backlog" in
109       Mojo::Server::Daemon.
110
111   clients
112         clients => 100
113
114       Maximum number of accepted connections each worker process is allowed
115       to handle concurrently, before stopping to accept new incoming
116       connections, defaults to the value of "max_connections" in
117       Mojo::IOLoop. Note that high concurrency works best with applications
118       that perform mostly non-blocking operations, to optimize for blocking
119       operations you can decrease this value and increase "workers" instead
120       for better performance.
121
122   graceful_timeout
123         graceful_timeout => 15
124
125       Maximum amount of time in seconds stopping a worker gracefully may take
126       before being forced, defaults to the value of "graceful_timeout" in
127       Mojo::Server::Prefork. Note that this value should usually be a little
128       larger than the maximum amount of time you expect any one request to
129       take.
130
131   heartbeat_interval
132         heartbeat_interval => 3
133
134       Heartbeat interval in seconds, defaults to the value of
135       "heartbeat_interval" in Mojo::Server::Prefork.
136
137   heartbeat_timeout
138         heartbeat_timeout => 2
139
140       Maximum amount of time in seconds before a worker without a heartbeat
141       will be stopped gracefully, defaults to the value of
142       "heartbeat_timeout" in Mojo::Server::Prefork. Note that this value
143       should usually be a little larger than the maximum amount of time you
144       expect any one operation to block the event loop.
145
146   inactivity_timeout
147         inactivity_timeout => 10
148
149       Maximum amount of time in seconds a connection with an active request
150       can be inactive before getting closed, defaults to the value of
151       "inactivity_timeout" in Mojo::Server::Daemon. Setting the value to 0
152       will allow connections to be inactive indefinitely.
153
154   keep_alive_timeout
155         keep_alive_timeout => 10
156
157       Maximum amount of time in seconds a connection without an active
158       request can be inactive before getting closed, defaults to the value of
159       "keep_alive_timeout" in Mojo::Server::Daemon. Setting the value to 0
160       will allow connections to be inactive indefinitely.
161
162   listen
163         listen => ['http://*:80']
164
165       Array reference with one or more locations to listen on, defaults to
166       "http://*:8080". See also "listen" in Mojo::Server::Daemon for more
167       examples.
168
169   pid_file
170         pid_file => '/var/run/hypnotoad.pid'
171
172       Full path to process id file, defaults to "hypnotoad.pid" in the same
173       directory as the application. Note that this value can only be changed
174       after the server has been stopped.
175
176   proxy
177         proxy => 1
178
179       Activate reverse proxy support, which allows for the "X-Forwarded-For"
180       and "X-Forwarded-Proto" headers to be picked up automatically, defaults
181       to the value of "reverse_proxy" in Mojo::Server.
182
183   requests
184         requests => 50
185
186       Number of keep-alive requests per connection, defaults to the value of
187       "max_requests" in Mojo::Server::Daemon.
188
189   spare
190         spare => 4
191
192       Temporarily spawn up to this number of additional workers if there is a
193       need, defaults to the value of "spare" in Mojo::Server::Prefork. This
194       allows for new workers to be started while old ones are still shutting
195       down gracefully, drastically reducing the performance cost of worker
196       restarts.
197
198   upgrade_timeout
199         upgrade_timeout => 45
200
201       Maximum amount of time in seconds a zero downtime software upgrade may
202       take before getting canceled, defaults to 180.
203
204   workers
205         workers => 10
206
207       Number of worker processes, defaults to the value of "workers" in
208       Mojo::Server::Prefork. A good rule of thumb is two worker processes per
209       CPU core for applications that perform mostly non-blocking operations,
210       blocking operations often require more and benefit from decreasing
211       concurrency with "clients" (often as low as 1). Note that during zero
212       downtime software upgrades there will be twice as many workers active
213       for a short amount of time.
214

ATTRIBUTES

216       Mojo::Server::Hypnotoad implements the following attributes.
217
218   prefork
219         my $prefork = $hypnotoad->prefork;
220         $hypnotoad  = $hypnotoad->prefork(Mojo::Server::Prefork->new);
221
222       Mojo::Server::Prefork object this server manages.
223
224   upgrade_timeout
225         my $timeout = $hypnotoad->upgrade_timeout;
226         $hypnotoad  = $hypnotoad->upgrade_timeout(15);
227
228       Maximum amount of time in seconds a zero downtime software upgrade may
229       take before getting canceled, defaults to 180.
230

METHODS

232       Mojo::Server::Hypnotoad inherits all methods from Mojo::Base and
233       implements the following new ones.
234
235   configure
236         $hypnotoad->configure('hypnotoad');
237
238       Configure server from application settings.
239
240   run
241         $hypnotoad->run('script/my_app');
242
243       Run server for application and wait for "MANAGER SIGNALS".
244

SEE ALSO

246       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
247
248
249
250perl v5.32.0                      2020-07-28        Mojo::Server::Hypnotoad(3)
Impressum