- SEE ALSO
Mojo::Server::Hypnotoad - ALL GLORY TO THE HYPNOTOAD!
use Mojo::Server::Hypnotoad; my $toad = Mojo::Server::Hypnotoad->new; $toad->run('./myapp.pl');
Mojo::Server::Hypnotoad is a full featured UNIX optimized preforking non-blocking I/O HTTP and WebSocket server built around the very well tested and reliable Mojo::Server::Daemon with
libev and hot deployment support that just works.
To start applications with it you can use the hypnotoad script.
$ hypnotoad myapp.pl Server available at http://127.0.0.1:8080.
You can run the exact same command again for automatic hot deployment.
$ hypnotoad myapp.pl Starting hot deployment for Hypnotoad server 31841.
Optional modules EV (4.0+), IO::Socket::IP (0.16+) and IO::Socket::SSL (1.75+) are supported transparently and used if installed. Individual features can also be disabled with the
MOJO_NO_TLS environment variables.
See Mojolicious::Guides::Cookbook for more.
Mojo::Server::Hypnotoad can be controlled at runtime with the following signals.
Shutdown server immediately.
Shutdown server gracefully.
Increase worker pool by one.
Decrease worker pool by one.
Attempt zero downtime software upgrade (hot deployment) without losing any incoming connections.
Manager (old) |- Worker  |- Worker  |- Worker  |- Worker  +- Manager (new) |- Worker  |- Worker  |- Worker  +- Worker 
The new manager will automatically send a
QUITsignal to the old manager and take over serving requests after starting up successfully.
accepts => 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 indefinitely. Note that up to half of this value can be subtracted randomly to improve load balancing, and that worker processes will stop sending heartbeat messages once the limit has been reached.
backlog => 128
Listen backlog size, defaults to
clients => 100
Maximum number of parallel client connections per worker process, defaults to
1000. Note that depending on how much your application may block, you might want to decrease this value and increase
workers instead for better performance.
graceful_timeout => 15
Maximum amount of time in seconds stopping a worker gracefully may take before being forced, defaults to
group => 'staff'
Group name for worker processes.
heartbeat_interval => 3
Heartbeat interval in seconds, defaults to
heartbeat_timeout => 2
Maximum amount of time in seconds before a worker without a heartbeat will be stopped gracefully, defaults to
inactivity_timeout => 10
Maximum amount of time in seconds a connection can be inactive before getting closed, defaults to
15. Setting the value to
0 will allow connections to be inactive indefinitely.
keep_alive_requests => 50
Number of keep alive requests per connection, defaults to
listen => ['http://*:80']
List of one or more locations to listen on, defaults to
http://*:8080. See also "listen" in Mojo::Server::Daemon for more examples.
lock_file => '/tmp/hypnotoad.lock'
Full path of accept mutex lock file prefix, to which the process id will be appended, defaults to a random temporary path.
lock_timeout => 1
Maximum amount of time in seconds a worker may block when waiting for the accept mutex, defaults to
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.
proxy => 1
Activate reverse proxy support, defaults to the value of the
MOJO_REVERSE_PROXY environment variable.
upgrade_timeout => 45
Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to
user => 'sri'
Username for worker processes.
workers => 10
Number of worker processes, defaults to
4. A good rule of thumb is two worker processes per cpu core.
Run server for application.