Mojo::S...ypnotoad(3)
π NAME π
okay so bestie, this is the manual page for Mojo::Server::Hypnotoad β the header abbreviates it as Mojo::S...ypnotoad(3), and it comes from the User Contributed Perl Documentation. The actual name line is literally:
Mojo::Server::Hypnotoad β A production web serv...ALL GLORY TO THE HYPNOTOAD!
ALL GLORY TO THE HYPNOTOAD! πΈπ
β¨ SYNOPSIS β¨
use Mojo::Server::Hypnotoad;
my $hypnotoad = Mojo::Server::Hypnotoad->new;
$hypnotoad->run('/home/sri/myapp.pl');
π¦ 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. Fr fr, let the toad handle the signals.
To start applications with it you can use the hypnotoad script, which listens on port 8080, automatically daemonizes the server process and defaults to "production" mode for Mojolicious and Mojolicious::Lite applications.
$ hypnotoad ./myapp.pl
You can run the same command again for automatic hot deployment.
$ hypnotoad ./myapp.pl
Starting hot deployment for Hypnotoad server 31841.
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. It's giving zero-downtime main character energy. β¨
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 MOJO_NO_NNR, MOJO_NO_SOCKS and MOJO_NO_TLS environment variables. π§
See "DEPLOYMENT" in Mojolicious::Guides::Cookbook for more.
π MANAGER SIGNALS π
The Mojo::Server::Hypnotoad manager process can be controlled at runtime with the following signals. Think of these as the manager's group-chat reactions. π¬
π INT, TERM π
Shut down server immediately. Bye bestie, no grace period. π
πΈ QUIT πΈ
Shut down server gracefully.
π TTIN π
Increase worker pool by one. More workers, more slay. πͺ
π TTOU π
Decrease worker pool by one.
π₯ USR2 π₯
Attempt zero downtime software upgrade (hot deployment) without losing any incoming connections.
Manager (old)
|- Worker [1]
|- Worker [2]
|- Worker [3]
|- Worker [4]
+- Manager (new)
|- Worker [1]
|- Worker [2]
|- Worker [3]
+- Worker [4]
The new manager will automatically send a "QUIT" signal to the old manager and take over serving requests after starting up successfully. Iconic behavior, no cap. π
π¦ WORKER SIGNALS π¦
Mojo::Server::Hypnotoad worker processes can be controlled at runtime with the following signals.
π QUIT π
Stop worker gracefully.
π§ SETTINGS π§
Mojo::Server::Hypnotoad can be configured with the following settings, see "Hypnotoad" in Mojolicious::Guides::Cookbook for examples. Configuration era. π
π accepts
accepts => 100
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 0 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. Chaotic but strategic. Love that for us. β¨
π backlog
backlog => 128
Listen backlog size, defaults to the value of "backlog" in Mojo::Server::Daemon.
π clients
clients => 100
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. Vibe check: non-blocking apps eat this up. π«Ά
πΈ graceful_timeout
graceful_timeout => 15
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.
π¦ heartbeat_interval
heartbeat_interval => 3
Heartbeat interval in seconds, defaults to the value of "heartbeat_interval" in Mojo::Server::Prefork.
π heartbeat_timeout
heartbeat_timeout => 2
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. No heartbeat? No service. Periodt. π
π§ inactivity_timeout
inactivity_timeout => 10
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 0 will allow connections to be inactive indefinitely.
π keep_alive_timeout
keep_alive_timeout => 10
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 0 will allow connections to be inactive indefinitely.
π listen
listen => ['http://*:80']
Array reference with one or more locations to listen on, defaults to "http://*:8080". See also "listen" in Mojo::Server::Daemon for more examples. Pick your portal, bestie. π
π pid_file
pid_file => '/var/run/hypnotoad.pid'
Full path to process id file, defaults to "hypnotoad.pid" in the same directory as the application. Note that this value can only be changed after the server has been stopped. Don't try to change it while it's running, that's not the move. π
π₯ proxy
proxy => 1
Activate reverse proxy support, which allows for the "X-Forwarded-For" and "X-Forwarded-Proto" headers to be picked up automatically, defaults to the value of "reverse_proxy" in Mojo::Server.
β requests
requests => 50
Number of keep-alive requests per connection, defaults to the value of "max_requests" in Mojo::Server::Daemon.
π spare
spare => 4
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. Understudy workers?? We love a smooth transition. π
π trusted_proxies
trusted_proxies => ['10.0.0.0/8', '127.0.0.1', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7']
Trusted reverse proxies, addresses or networks in CIDR form.
π upgrade_timeout
upgrade_timeout => 45
Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to 180. Yes, the example says 45 and the default says 180 β copy that exactly, bestie. π
π workers
workers => 10
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 1). Note that during zero downtime software upgrades there will be twice as many workers active for a short amount of time. Double workers for a hot second β upgrade szn. π₯
π ATTRIBUTES π
Mojo::Server::Hypnotoad implements the following attributes. Attribute check, bestie. β¨
πΈ prefork
my $prefork = $hypnotoad->prefork;
$hypnotoad = $hypnotoad->prefork(Mojo::Server::Prefork->new);
Mojo::Server::Prefork object this server manages. This is the little engine that could. π
π¦ upgrade_timeout
my $timeout = $hypnotoad->upgrade_timeout;
$hypnotoad = $hypnotoad->upgrade_timeout(15);
Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to 180.
β¨ METHODS β¨
Mojo::Server::Hypnotoad inherits all methods from Mojo::Base and implements the following new ones.
π configure
$hypnotoad->configure('hypnotoad');
Configure server from application settings.
π run
$hypnotoad->run('script/my_app');
Run server for application and wait for "MANAGER SIGNALS". Then it's toad business as usual. πΈ
π SEE ALSO π
Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
mwah π this page is from perl v5.42.0, dated 2026-07-15, and the footer still abbreviates the name as Mojo::S...ypnotoad(3). π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms