| Mojolicious documentation | view source | Contained in the Mojolicious distribution. |
Mojo::Server::Hypnotoad - ALL GLORY TO THE HYPNOTOAD!
use Mojo::Server::Hypnotoad;
my $toad = Mojo::Server::Hypnotoad->new;
$toad->run('./myapp.pl', './hypnotoad.conf');
Mojo::Server::Hypnotoad is a full featured UNIX optimized preforking async
io HTTP 1.1 and WebSocket server built around the very well tested and
reliable Mojo::Server::Daemon with IPv6, TLS, Bonjour, epoll,
kqueue and hot deployment support that just works.
To start applications with it you can use the hypnotoad script.
% hypnotoad myapp.pl
Optional modules IO::KQueue, IO::Epoll, IO::Socket::IP, IO::Socket::SSL and Net::Rendezvous::Publish are supported transparently and used if installed.
See Mojolicious::Guides::Cookbook for deployment recipes.
You can control hypnotoad at runtime with signals.
INT, TERMShutdown server immediately.
QUITShutdown server gracefully.
TTINIncrease worker pool by one.
TTOUDecrease worker pool by one.
USR2Attempt zero downtime software upgrade (hot deployment) without losing any incoming connections.
Manager (old)
|- Worker [1]
|- Worker [2]
|- Worker [3]
|- Worker [4]
`- Manager
|- 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.
INT, TERMStop worker immediately.
QUITStop worker gracefully.
Hypnotoad configuration files are normal Perl scripts returning a hash.
# hypnotoad.conf
{listen => ['http://*:3000', 'http://*:4000'], workers => 10};
The following parameters are currently available:
acceptsaccepts => 100
Maximum number of connections a worker is allowed to accept before stopping
gracefully, defaults to 1000.
Setting the value to 0 will allow workers to accept new connections
infinitely.
backlogbacklog => 128
Listen backlog size, defaults to SOMAXCONN.
clientsclients => 100
Maximum number of parallel client connections per worker process, defaults to
1000.
graceful_timeoutgraceful_timeout => 15
Time in seconds a graceful worker stop may take before being forced, defaults
to 30.
groupgroup => 'staff'
Group name for worker processes.
heartbeat_intervalheartbeat_interval => 3
Heartbeat interval in seconds, defaults to 5.
heartbeat_timeoutheartbeat_timeout => 5
Time in seconds before a worker without a heartbeat will be stopped, defaults
to 2.
keep_alive_requestskeep_alive_requests => 50
Number of keep alive requests per connection, defaults to 25.
keep_alive_timeoutkeep_alive_timeout => 10
Maximum amount of time in seconds a connection can be inactive before being
dropped, defaults to 5.
listenlisten => ['http://*:80']
List of ports and files to listen on, defaults to http://*:8080.
lock_filelock_file => '/tmp/hypnotoad.lock'
Full path to accept mutex lock file, defaults to a random temporary file.
pid_filepid_file => '/var/run/hypnotoad.pid'
Full path to PID file, defaults to hypnotoad.pid in the same directory as
the application.
proxyproxy => 1
Activate reverse proxy support, defaults to the value of
MOJO_REVERSE_PROXY.
upgrade_timeoutupgrade_timeout => 15
Time in seconds a zero downtime software upgrade may take before being
aborted, defaults to 30.
useruser => 'sri'
User name for worker processes.
websocket_timeoutwebsocket_timeout => 150
Maximum amount of time in seconds a WebSocket connection can be inactive
before being dropped, defaults to 300.
workersworkers => 10
Number of worker processes, defaults to 4.
A good rule of thumb is two worker processes per cpu core.
Mojo::Server::Hypnotoad inherits all methods from Mojo::Base and implements the following new ones.
run $toad->run('script/myapp', 'hypnotoad.conf');
Start server.
You can set the HYPNOTOAD_DEBUG environment variable to get some advanced
diagnostics information printed to STDERR.
HYPNOTOAD_DEBUG=1
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
| Mojolicious documentation | view source | Contained in the Mojolicious distribution. |