1Mojo::Server::Daemon(3)User Contributed Perl DocumentatioMnojo::Server::Daemon(3)
2
3
4
6 Mojo::Server::Daemon - Async IO HTTP 1.1 And WebSocket Server
7
9 use Mojo::Server::Daemon;
10
11 my $daemon = Mojo::Server::Daemon->new;
12 $daemon->listen('http://*:8080');
13 $daemon->run;
14
16 Mojo::Server::Daemon is a full featured async io HTTP 1.1 and WebSocket
17 server with "IPv6", "TLS", "Bonjour", "epoll", "kqueue", hot deployment
18 and UNIX domain socket sharing support.
19
20 Optional modules IO::KQueue, IO::Epoll, IO::Socket::INET6,
21 IO::Socket::SSL and Net::Rendezvous::Publish are supported
22 transparently and used if installed.
23
25 Mojo::Server::Daemon inherits all attributes from Mojo::Server and
26 implements the following new ones.
27
28 "group"
29 my $group = $daemon->group;
30 $daemon = $daemon->group('users');
31
32 Group for server process.
33
34 "ioloop"
35 my $loop = $daemon->ioloop;
36 $daemon = $daemon->ioloop(Mojo::IOLoop->new);
37
38 Event loop for server IO, defaults to the global Mojo::IOLoop
39 singleton.
40
41 "keep_alive_timeout"
42 my $keep_alive_timeout = $daemon->keep_alive_timeout;
43 $daemon = $daemon->keep_alive_timeout(15);
44
45 Timeout for keep alive connections in seconds, defaults to 15.
46
47 "listen"
48 my $listen = $daemon->listen;
49 $daemon = $daemon->listen('https://localhost:3000,file:///my.sock');
50
51 Ports and files to listen on, defaults to "http://*:3000".
52
53 "listen_queue_size"
54 my $listen_queue_size = $daemon->listen_queue_zise;
55 $daemon = $daemon->listen_queue_zise(128);
56
57 Listen queue size, defaults to "SOMAXCONN".
58
59 "max_clients"
60 my $max_clients = $daemon->max_clients;
61 $daemon = $daemon->max_clients(1000);
62
63 Maximum number of parallel client connections, defaults to 1000.
64
65 "max_keep_alive_requests"
66 my $max_keep_alive_requests = $daemon->max_keep_alive_requests;
67 $daemon = $daemon->max_keep_alive_requests(100);
68
69 Maximum number of keep alive requests per connection, defaults to 100.
70
71 "max_requests"
72 my $max_requests = $daemon->max_requests;
73 $daemon = $daemon->max_requests(1);
74
75 Maximum number of requests the daemon is allowed to handle, not used by
76 default.
77
78 "pid_file"
79 my $pid_file = $daemon->pid_file;
80 $daemon = $daemon->pid_file('/tmp/mojo_daemon.pid');
81
82 Path to process id file, defaults to a random temporary file.
83
84 "silent"
85 my $silent = $daemon->silent;
86 $daemon = $daemon->silent(1);
87
88 Disable console messages.
89
90 "user"
91 my $user = $daemon->user;
92 $daemon = $daemon->user('web');
93
94 User for the server process.
95
96 "websocket_timeout"
97 my $websocket_timeout = $server->websocket_timeout;
98 $server = $server->websocket_timeout(300);
99
100 Timeout in seconds for WebSockets to be idle, defaults to 300.
101
103 Mojo::Server::Daemon inherits all methods from Mojo::Server and
104 implements the following new ones.
105
106 "prepare_ioloop"
107 $daemon->prepare_ioloop;
108
109 Prepare event loop.
110
111 "prepare_pid_file"
112 $daemon->prepare_pid_file;
113
114 Prepare process id file.
115
116 "run"
117 $daemon->run;
118
119 Start server.
120
121 "setuidgid"
122 $daemon->setuidgid;
123
124 Set user and group for process.
125
127 Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
128
129
130
131perl v5.12.3 2010-08-17 Mojo::Server::Daemon(3)