.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mojo::Server::Daemon 3pm" .TH Mojo::Server::Daemon 3pm "2012-09-05" "perl v5.14.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::Daemon \- Non\-blocking I/O HTTP 1.1 and WebSocket server .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::Server::Daemon; \& \& my $daemon = Mojo::Server::Daemon\->new(listen => [\*(Aqhttp://*:8080\*(Aq]); \& $daemon\->unsubscribe(\*(Aqrequest\*(Aq); \& $daemon\->on(request => sub { \& my ($daemon, $tx) = @_; \& \& # Request \& my $method = $tx\->req\->method; \& my $path = $tx\->req\->url\->path; \& \& # Response \& $tx\->res\->code(200); \& $tx\->res\->headers\->content_type(\*(Aqtext/plain\*(Aq); \& $tx\->res\->body("$method request for $path!"); \& \& # Resume transaction \& $tx\->resume; \& }); \& $daemon\->run; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojo::Server::Daemon is a full featured non-blocking I/O \s-1HTTP\s0 1.1 and WebSocket server with \f(CW\*(C`IPv6\*(C'\fR, \f(CW\*(C`TLS\*(C'\fR and \f(CW\*(C`libev\*(C'\fR support. .PP Optional modules \s-1EV\s0, IO::Socket::INET6 and IO::Socket::SSL are supported transparently and used if installed. Individual features can also be disabled with the \f(CW\*(C`MOJO_NO_IPV6\*(C'\fR and \f(CW\*(C`MOJO_NO_TLS\*(C'\fR environment variables. .PP See Mojolicious::Guides::Cookbook for more. .SH "EVENTS" .IX Header "EVENTS" Mojo::Server::Daemon inherits all events from Mojo::Server. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo::Server::Daemon inherits all attributes from Mojo::Server and implements the following new ones. .ie n .SS """backlog""" .el .SS "\f(CWbacklog\fP" .IX Subsection "backlog" .Vb 2 \& my $backlog = $daemon\->backlog; \& $daemon = $daemon\->backlog(128); .Ve .PP Listen backlog size, defaults to \f(CW\*(C`SOMAXCONN\*(C'\fR. .ie n .SS """group""" .el .SS "\f(CWgroup\fP" .IX Subsection "group" .Vb 2 \& my $group = $daemon\->group; \& $daemon = $daemon\->group(\*(Aqusers\*(Aq); .Ve .PP Group for server process. .ie n .SS """inactivity_timeout""" .el .SS "\f(CWinactivity_timeout\fP" .IX Subsection "inactivity_timeout" .Vb 2 \& my $timeout = $daemon\->inactivity_timeout; \& $daemon = $daemon\->inactivity_timeout(5); .Ve .PP Maximum amount of time in seconds a connection can be inactive before getting closed, defaults to the value of the \f(CW\*(C`MOJO_INACTIVITY_TIMEOUT\*(C'\fR environment variable or \f(CW15\fR. Setting the value to \f(CW0\fR will allow connections to be inactive indefinitely. .ie n .SS """ioloop""" .el .SS "\f(CWioloop\fP" .IX Subsection "ioloop" .Vb 2 \& my $loop = $daemon\->ioloop; \& $daemon = $daemon\->ioloop(Mojo::IOLoop\->new); .Ve .PP Loop object to use for I/O operations, defaults to the global Mojo::IOLoop singleton. .ie n .SS """listen""" .el .SS "\f(CWlisten\fP" .IX Subsection "listen" .Vb 2 \& my $listen = $daemon\->listen; \& $daemon = $daemon\->listen([\*(Aqhttps://localhost:3000\*(Aq]); .Ve .PP List of one or more locations to listen on, defaults to the value of the \&\f(CW\*(C`MOJO_LISTEN\*(C'\fR environment variable or \f(CW\*(C`http://*:3000\*(C'\fR. .PP .Vb 2 \& # Listen on IPv6 interface \& $daemon\->listen([\*(Aqhttp://[::1]:4000\*(Aq]); \& \& # Listen on two ports with HTTP and HTTPS at the same time \& $daemon\->listen([qw(http://*:3000 https://*:4000)]); \& \& # Use a custom certificate and key \& $daemon\->listen([\*(Aqhttps://*:3000?cert=/x/server.crt&key=/y/server.key\*(Aq]); \& \& # Or even a custom certificate authority \& $daemon\->listen( \& [\*(Aqhttps://*:3000?cert=/x/server.crt&key=/y/server.key&ca=/z/ca.crt\*(Aq]); .Ve .PP These parameters are currently available: .ie n .IP """ca""" 4 .el .IP "\f(CWca\fR" 4 .IX Item "ca" Path to \s-1TLS\s0 certificate authority file. .ie n .IP """cert""" 4 .el .IP "\f(CWcert\fR" 4 .IX Item "cert" Path to the \s-1TLS\s0 cert file, defaults to a built-in test certificate. .ie n .IP """key""" 4 .el .IP "\f(CWkey\fR" 4 .IX Item "key" Path to the \s-1TLS\s0 key file, defaults to a built-in test key. .ie n .SS """max_clients""" .el .SS "\f(CWmax_clients\fP" .IX Subsection "max_clients" .Vb 2 \& my $max_clients = $daemon\->max_clients; \& $daemon = $daemon\->max_clients(1000); .Ve .PP Maximum number of parallel client connections, defaults to \f(CW1000\fR. .ie n .SS """max_requests""" .el .SS "\f(CWmax_requests\fP" .IX Subsection "max_requests" .Vb 2 \& my $max_requests = $daemon\->max_requests; \& $daemon = $daemon\->max_requests(100); .Ve .PP Maximum number of keep alive requests per connection, defaults to \f(CW25\fR. .ie n .SS """silent""" .el .SS "\f(CWsilent\fP" .IX Subsection "silent" .Vb 2 \& my $silent = $daemon\->silent; \& $daemon = $daemon\->silent(1); .Ve .PP Disable console messages. .ie n .SS """user""" .el .SS "\f(CWuser\fP" .IX Subsection "user" .Vb 2 \& my $user = $daemon\->user; \& $daemon = $daemon\->user(\*(Aqweb\*(Aq); .Ve .PP User for the server process. .SH "METHODS" .IX Header "METHODS" Mojo::Server::Daemon inherits all methods from Mojo::Server and implements the following new ones. .ie n .SS """run""" .el .SS "\f(CWrun\fP" .IX Subsection "run" .Vb 1 \& $daemon\->run; .Ve .PP Run server. .ie n .SS """setuidgid""" .el .SS "\f(CWsetuidgid\fP" .IX Subsection "setuidgid" .Vb 1 \& $daemon = $daemon\->setuidgid; .Ve .PP Set user and group for process. .ie n .SS """start""" .el .SS "\f(CWstart\fP" .IX Subsection "start" .Vb 1 \& $daemon\->start; .Ve .PP Start accepting connections. .SH "DEBUGGING" .IX Header "DEBUGGING" You can set the \f(CW\*(C`MOJO_DAEMON_DEBUG\*(C'\fR environment variable to get some advanced diagnostics information printed to \f(CW\*(C`STDERR\*(C'\fR. .PP .Vb 1 \& MOJO_DAEMON_DEBUG=1 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .