++ed by:
KMX UKSZA MUGIFLY SZABGAB ANDREFS

122 PAUSE users
154 non-PAUSE users.

Abhijit Menon-Sen
and 1 contributors

NAME

Mojo::Server::Hypnotoad - ALL GLORY TO THE HYPNOTOAD!

SYNOPSIS

  use Mojo::Server::Hypnotoad;

  my $toad = Mojo::Server::Hypnotoad->new;
  $toad->run('./myapp.pl');

DESCRIPTION

Mojo::Server::Hypnotoad is a full featured UNIX optimized preforking non-blocking I/O HTTP 1.1 and WebSocket server built around the very well tested and reliable Mojo::Server::Daemon with IPv6, TLS, Bonjour, 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.

For Mojolicious and Mojolicious::Lite applications it will default to production mode.

Optional modules EV, IO::Socket::IP, IO::Socket::SSL and Net::Rendezvous::Publish are supported transparently and used if installed.

See Mojolicious::Guides::Cookbook for deployment recipes.

SIGNALS

Mojo::Server::Hypnotoad can be controlled at runtime with the following signals.

Manager

INT, TERM

Shutdown server immediately.

QUIT

Shutdown server gracefully.

TTIN

Increase worker pool by one.

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.

Worker

INT, TERM

Stop worker immediately.

QUIT

Stop worker gracefully.

SETTINGS

Mojo::Server::Hypnotoad can be configured with the following settings, see "Hypnotoad" in Mojolicious::Guides::Cookbook for examples.

accepts

  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 infinitely.

backlog

  backlog => 128

Listen backlog size, defaults to SOMAXCONN.

clients

  clients => 100

Maximum number of parallel client connections per worker process, defaults to 1000.

graceful_timeout

  graceful_timeout => 15

Maximum amount of time in seconds a graceful worker stop may take before being forced, defaults to 30.

group

  group => 'staff'

Group name for worker processes.

heartbeat_interval

  heartbeat_interval => 3

Heartbeat interval in seconds, defaults to 5.

heartbeat_timeout

  heartbeat_timeout => 2

Maximum amount of time in seconds before a worker without a heartbeat will be stopped, defaults to 10.

inactivity_timeout

  inactivity_timeout => 10

Maximum amount of time in seconds a connection can be inactive before getting dropped, defaults to 15. Setting the value to 0 will allow connections to be inactive indefinitely.

keep_alive_requests

  keep_alive_requests => 50

Number of keep alive requests per connection, defaults to 25.

listen

  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

  lock_file => '/tmp/hypnotoad.lock'

Full path to accept mutex lock file, defaults to a random temporary file.

lock_timeout

  lock_timeout => 1

Maximum amount of time in seconds a worker may block when waiting for the accept mutex, defaults to 0.5.

pid_file

  pid_file => '/var/run/hypnotoad.pid'

Full path to PID file, defaults to hypnotoad.pid in the same directory as the application.

proxy

  proxy => 1

Activate reverse proxy support, defaults to the value of the MOJO_REVERSE_PROXY environment variable.

upgrade_timeout

  upgrade_timeout => 30

Maximum amount of time in seconds a zero downtime software upgrade may take before getting canceled, defaults to 60.

user

  user => 'sri'

Username for worker processes.

websocket_timeout

  websocket_timeout => 150

Maximum amount of time in seconds a WebSocket connection can be inactive before getting dropped, defaults to 300. Setting the value to 0 will allow WebSocket connections to be inactive indefinitely.

workers

  workers => 10

Number of worker processes, defaults to 4. A good rule of thumb is two worker processes per cpu core.

METHODS

Mojo::Server::Hypnotoad inherits all methods from Mojo::Base and implements the following new ones.

run

  $toad->run('script/myapp');

Run server.

DEBUGGING

You can set the HYPNOTOAD_DEBUG environment variable to get some advanced diagnostics information printed to STDERR.

  HYPNOTOAD_DEBUG=1

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.