.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mojo::Server::Hypnotoad 3pm" .TH Mojo::Server::Hypnotoad 3pm 2024-05-15 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Mojo::Server::Hypnotoad \- A production web serv...ALL GLORY TO THE HYPNOTOAD! .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::Server::Hypnotoad; \& \& my $hypnotoad = Mojo::Server::Hypnotoad\->new; \& $hypnotoad\->run(\*(Aq/home/sri/myapp.pl\*(Aq); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Mojo::Server::Hypnotoad is a full featured, UNIX optimized, pre-forking non-blocking I/O HTTP and WebSocket server, built around the very well tested and reliable Mojo::Server::Prefork, with IPv6, TLS, SNI, UNIX domain socket, Comet (long polling), keep-alive, multiple event loop and hot deployment support that just works. Note that the server uses signals for process management, so you should avoid modifying signal handlers in your applications. .PP To start applications with it you can use the hypnotoad script, which listens on port \f(CW8080\fR, automatically daemonizes the server process and defaults to \f(CW\*(C`production\*(C'\fR mode for Mojolicious and Mojolicious::Lite applications. .PP .Vb 1 \& $ hypnotoad ./myapp.pl .Ve .PP You can run the same command again for automatic hot deployment. .PP .Vb 2 \& $ hypnotoad ./myapp.pl \& Starting hot deployment for Hypnotoad server 31841. .Ve .PP This second invocation will load the application again, detect the process id file with it, and send a "USR2" signal to the already running server. .PP For better scalability (epoll, kqueue) and to provide non-blocking name resolution, SOCKS5 as well as TLS support, the optional modules EV (4.32+), Net::DNS::Native (0.15+), IO::Socket::Socks (0.64+) and IO::Socket::SSL (2.009+) will be used automatically if possible. Individual features can also be disabled with the \f(CW\*(C`MOJO_NO_NNR\*(C'\fR, \&\f(CW\*(C`MOJO_NO_SOCKS\*(C'\fR and \f(CW\*(C`MOJO_NO_TLS\*(C'\fR environment variables. .PP See "DEPLOYMENT" in Mojolicious::Guides::Cookbook for more. .SH "MANAGER SIGNALS" .IX Header "MANAGER SIGNALS" The Mojo::Server::Hypnotoad manager process can be controlled at runtime with the following signals. .SS "INT, TERM" .IX Subsection "INT, TERM" Shut down server immediately. .SS QUIT .IX Subsection "QUIT" Shut down server gracefully. .SS TTIN .IX Subsection "TTIN" Increase worker pool by one. .SS TTOU .IX Subsection "TTOU" Decrease worker pool by one. .SS USR2 .IX Subsection "USR2" Attempt zero downtime software upgrade (hot deployment) without losing any incoming connections. .PP .Vb 10 \& Manager (old) \& |\- Worker [1] \& |\- Worker [2] \& |\- Worker [3] \& |\- Worker [4] \& +\- Manager (new) \& |\- Worker [1] \& |\- Worker [2] \& |\- Worker [3] \& +\- Worker [4] .Ve .PP The new manager will automatically send a "QUIT" signal to the old manager and take over serving requests after starting up successfully. .SH "WORKER SIGNALS" .IX Header "WORKER SIGNALS" Mojo::Server::Hypnotoad worker processes can be controlled at runtime with the following signals. .SS QUIT .IX Subsection "QUIT" Stop worker gracefully. .SH SETTINGS .IX Header "SETTINGS" Mojo::Server::Hypnotoad can be configured with the following settings, see "Hypnotoad" in Mojolicious::Guides::Cookbook for examples. .SS accepts .IX Subsection "accepts" .Vb 1 \& accepts => 100 .Ve .PP Maximum number of connections a worker is allowed to accept, before stopping gracefully and then getting replaced with a newly started worker, defaults to the value of "accepts" in Mojo::Server::Prefork. Setting the value to \f(CW0\fR will allow workers to accept new connections indefinitely. Note that up to half of this value can be subtracted randomly to improve load balancing, and to make sure that not all workers restart at the same time. .SS backlog .IX Subsection "backlog" .Vb 1 \& backlog => 128 .Ve .PP Listen backlog size, defaults to the value of "backlog" in Mojo::Server::Daemon. .SS clients .IX Subsection "clients" .Vb 1 \& clients => 100 .Ve .PP Maximum number of accepted connections each worker process is allowed to handle concurrently, before stopping to accept new incoming connections, defaults to the value of "max_connections" in Mojo::IOLoop. Note that high concurrency works best with applications that perform mostly non-blocking operations, to optimize for blocking operations you can decrease this value and increase "workers" instead for better performance. .SS graceful_timeout .IX Subsection "graceful_timeout" .Vb 1 \& graceful_timeout => 15 .Ve .PP Maximum amount of time in seconds stopping a worker gracefully may take before being forced, defaults to the value of "graceful_timeout" in Mojo::Server::Prefork. Note that this value should usually be a little larger than the maximum amount of time you expect any one request to take. .SS heartbeat_interval .IX Subsection "heartbeat_interval" .Vb 1 \& heartbeat_interval => 3 .Ve .PP Heartbeat interval in seconds, defaults to the value of "heartbeat_interval" in Mojo::Server::Prefork. .SS heartbeat_timeout .IX Subsection "heartbeat_timeout" .Vb 1 \& heartbeat_timeout => 2 .Ve .PP Maximum amount of time in seconds before a worker without a heartbeat will be stopped gracefully, defaults to the value of "heartbeat_timeout" in Mojo::Server::Prefork. Note that this value should usually be a little larger than the maximum amount of time you expect any one operation to block the event loop. .SS inactivity_timeout .IX Subsection "inactivity_timeout" .Vb 1 \& inactivity_timeout => 10 .Ve .PP Maximum amount of time in seconds a connection with an active request can be inactive before getting closed, defaults to the value of "inactivity_timeout" in Mojo::Server::Daemon. Setting the value to \f(CW0\fR will allow connections to be inactive indefinitely. .SS keep_alive_timeout .IX Subsection "keep_alive_timeout" .Vb 1 \& keep_alive_timeout => 10 .Ve .PP Maximum amount of time in seconds a connection without an active request can be inactive before getting closed, defaults to the value of "keep_alive_timeout" in Mojo::Server::Daemon. Setting the value to \f(CW0\fR will allow connections to be inactive indefinitely. .SS listen .IX Subsection "listen" .Vb 1 \& listen => [\*(Aqhttp://*:80\*(Aq] .Ve .PP Array reference with one or more locations to listen on, defaults to \f(CW\*(C`http://*:8080\*(C'\fR. See also "listen" in Mojo::Server::Daemon for more examples. .SS pid_file .IX Subsection "pid_file" .Vb 1 \& pid_file => \*(Aq/var/run/hypnotoad.pid\*(Aq .Ve .PP Full path to process id file, defaults to \f(CW\*(C`hypnotoad.pid\*(C'\fR in the same directory as the application. Note that this value can only be changed after the server has been stopped. .SS proxy .IX Subsection "proxy" .Vb 1 \& proxy => 1 .Ve .PP Activate reverse proxy support, which allows for the \f(CW\*(C`X\-Forwarded\-For\*(C'\fR and \f(CW\*(C`X\-Forwarded\-Proto\*(C'\fR headers to be picked up automatically, defaults to the value of "reverse_proxy" in Mojo::Server. .SS requests .IX Subsection "requests" .Vb 1 \& requests => 50 .Ve .PP Number of keep-alive requests per connection, defaults to the value of "max_requests" in Mojo::Server::Daemon. .SS spare .IX Subsection "spare" .Vb 1 \& spare => 4 .Ve .PP Temporarily spawn up to this number of additional workers if there is a need, defaults to the value of "spare" in Mojo::Server::Prefork. This allows for new workers to be started while old ones are still shutting down gracefully, drastically reducing the performance cost of worker restarts. .SS trusted_proxies .IX Subsection "trusted_proxies" .Vb 1 \& trusted_proxies => [\*(Aq10.0.0.0/8\*(Aq, \*(Aq127.0.0.1\*(Aq, \*(Aq172.16.0.0/12\*(Aq, \*(Aq192.168.0.0/16\*(Aq, \*(Aqfc00::/7\*(Aq] .Ve .PP Trusted reverse proxies, addresses or networks in CIDR form. .SS upgrade_timeout .IX Subsection "upgrade_timeout" .Vb 1 \& upgrade_timeout => 45 .Ve .PP Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to \&\f(CW180\fR. .SS workers .IX Subsection "workers" .Vb 1 \& workers => 10 .Ve .PP Number of worker processes, defaults to the value of "workers" in Mojo::Server::Prefork. A good rule of thumb is two worker processes per CPU core for applications that perform mostly non-blocking operations, blocking operations often require more and benefit from decreasing concurrency with "clients" (often as low as \f(CW1\fR). Note that during zero downtime software upgrades there will be twice as many workers active for a short amount of time. .SH ATTRIBUTES .IX Header "ATTRIBUTES" Mojo::Server::Hypnotoad implements the following attributes. .SS prefork .IX Subsection "prefork" .Vb 2 \& my $prefork = $hypnotoad\->prefork; \& $hypnotoad = $hypnotoad\->prefork(Mojo::Server::Prefork\->new); .Ve .PP Mojo::Server::Prefork object this server manages. .SS upgrade_timeout .IX Subsection "upgrade_timeout" .Vb 2 \& my $timeout = $hypnotoad\->upgrade_timeout; \& $hypnotoad = $hypnotoad\->upgrade_timeout(15); .Ve .PP Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to \&\f(CW180\fR. .SH METHODS .IX Header "METHODS" Mojo::Server::Hypnotoad inherits all methods from Mojo::Base and implements the following new ones. .SS configure .IX Subsection "configure" .Vb 1 \& $hypnotoad\->configure(\*(Aqhypnotoad\*(Aq); .Ve .PP Configure server from application settings. .SS run .IX Subsection "run" .Vb 1 \& $hypnotoad\->run(\*(Aqscript/my_app\*(Aq); .Ve .PP Run server for application and wait for "MANAGER SIGNALS". .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .