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   trusted_proxies
199         trusted_proxies => ['10.0.0.0/8', '127.0.0.1', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7']
200
201       Trusted reverse proxies, addresses or networks in CIDR form.
202
203   upgrade_timeout
204         upgrade_timeout => 45
205
206       Maximum amount of time in seconds a zero downtime software upgrade may
207       take before getting canceled, defaults to 180.
208
209   workers
210         workers => 10
211
212       Number of worker processes, defaults to the value of "workers" in
213       Mojo::Server::Prefork. A good rule of thumb is two worker processes per
214       CPU core for applications that perform mostly non-blocking operations,
215       blocking operations often require more and benefit from decreasing
216       concurrency with "clients" (often as low as 1). Note that during zero
217       downtime software upgrades there will be twice as many workers active
218       for a short amount of time.
219

ATTRIBUTES

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

METHODS

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

SEE ALSO

251       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
252
253
254
255perl v5.36.0                      2023-01-20        Mojo::Server::Hypnotoad(3)
Impressum