File Coverage

blib/lib/Mojolicious/Command/daemon.pm
Criterion Covered Total %
statement 9 19 47.3
branch 0 2 0.0
condition n/a
subroutine 3 9 33.3
pod 1 1 100.0
total 13 31 41.9


line stmt bran cond sub pod time code
1             package Mojolicious::Command::daemon;
2 1     1   8 use Mojo::Base 'Mojolicious::Command';
  1         2  
  1         10  
3              
4 1     1   8 use Mojo::Server::Daemon;
  1         3  
  1         8  
5 1     1   7 use Mojo::Util 'getopt';
  1         2  
  1         358  
6              
7             has description => 'Start application with HTTP and WebSocket server';
8             has usage => sub { shift->extract_usage };
9              
10             sub run {
11 0     0 1   my ($self, @args) = @_;
12              
13 0           my $daemon = Mojo::Server::Daemon->new(app => $self->app);
14             getopt \@args,
15 0     0     'b|backlog=i' => sub { $daemon->backlog($_[1]) },
16 0     0     'c|clients=i' => sub { $daemon->max_clients($_[1]) },
17 0     0     'i|inactivity-timeout=i' => sub { $daemon->inactivity_timeout($_[1]) },
18             'l|listen=s' => \my @listen,
19 0     0     'p|proxy' => sub { $daemon->reverse_proxy(1) },
20 0     0     'r|requests=i' => sub { $daemon->max_requests($_[1]) };
  0            
21              
22 0 0         $daemon->listen(\@listen) if @listen;
23 0           $daemon->run;
24             }
25              
26             1;
27              
28             =encoding utf8
29              
30             =head1 NAME
31              
32             Mojolicious::Command::daemon - Daemon command
33              
34             =head1 SYNOPSIS
35              
36             Usage: APPLICATION daemon [OPTIONS]
37              
38             ./myapp.pl daemon
39             ./myapp.pl daemon -m production -l http://*:8080
40             ./myapp.pl daemon -l http://127.0.0.1:8080 -l https://[::]:8081
41             ./myapp.pl daemon -l 'https://*:443?cert=./server.crt&key=./server.key'
42             ./myapp.pl daemon -l http+unix://%2Ftmp%2Fmyapp.sock
43              
44             Options:
45             -b, --backlog Listen backlog size, defaults to
46             SOMAXCONN
47             -c, --clients Maximum number of concurrent
48             connections, defaults to 1000
49             -h, --help Show this summary of available options
50             --home Path to home directory of your
51             application, defaults to the value of
52             MOJO_HOME or auto-detection
53             -i, --inactivity-timeout Inactivity timeout, defaults to the
54             value of MOJO_INACTIVITY_TIMEOUT or 15
55             -l, --listen One or more locations you want to
56             listen on, defaults to the value of
57             MOJO_LISTEN or "http://*:3000"
58             -m, --mode Operating mode for your application,
59             defaults to the value of
60             MOJO_MODE/PLACK_ENV or "development"
61             -p, --proxy Activate reverse proxy support,
62             defaults to the value of
63             MOJO_REVERSE_PROXY
64             -r, --requests Maximum number of requests per
65             keep-alive connection, defaults to 100
66              
67             =head1 DESCRIPTION
68              
69             L starts applications with the
70             L backend.
71              
72             This is a core command, that means it is always enabled and its code a good
73             example for learning to build new commands, you're welcome to fork it.
74              
75             See L for a list of commands that are
76             available by default.
77              
78             =head1 ATTRIBUTES
79              
80             L inherits all attributes from
81             L and implements the following new ones.
82              
83             =head2 description
84              
85             my $description = $daemon->description;
86             $daemon = $daemon->description('Foo');
87              
88             Short description of this command, used for the command list.
89              
90             =head2 usage
91              
92             my $usage = $daemon->usage;
93             $daemon = $daemon->usage('Foo');
94              
95             Usage information for this command, used for the help screen.
96              
97             =head1 METHODS
98              
99             L inherits all methods from
100             L and implements the following new ones.
101              
102             =head2 run
103              
104             $daemon->run(@ARGV);
105              
106             Run this command.
107              
108             =head1 SEE ALSO
109              
110             L, L, L.
111              
112             =cut