File Coverage

blib/lib/CatalystX/Script/Server/Starman.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package CatalystX::Script::Server::Starman;
2 1     1   1760 use Moose;
  0            
  0            
3             use MooseX::Types::Moose qw/ Str Int /;
4             use Pod::Usage;
5             use Pod::Find qw(pod_where);
6             use namespace::autoclean;
7              
8             our $VERSION = '0.02';
9              
10             extends 'Catalyst::Script::Server';
11              
12             has '+fork' => ( default => 1, init_arg => undef );
13              
14             has [qw/ keepalive restart restart_delay restart_regex restart_directory/] => ( init_arg => undef, is => 'ro' );
15              
16             has workers => (
17             isa => Int,
18             is => 'ro',
19             default => 5,
20             );
21              
22             has [qw/
23             min_servers
24             min_spare_servers
25             max_spare_servers
26             max_servers
27             max_requests
28             backlog
29             /] => ( isa => Int, is => 'ro' );
30              
31             has [qw/
32             user
33             group
34             /] => ( isa => Str, is => 'ro' );
35              
36             around _plack_loader_args => sub {
37             my ($orig, $self, @args) = @_;
38             my %out = $self->$orig(@args);
39             foreach my $key (qw/
40             workers
41             min_servers
42             min_spare_servers
43             max_spare_servers
44             max_servers
45             max_requests
46             backlog
47             user
48             group
49             /) {
50             $out{$key} = $self->$key();
51             }
52             return %out;
53             };
54              
55             sub _getopt_full_usage {
56             my $self = shift;
57             pod2usage( -input => pod_where({-inc => 1}, __PACKAGE__), -verbose => 2 );
58             exit 0;
59             }
60              
61             1;
62              
63             =head1 NAME
64              
65             CatalystX::Script::Server::Starman - Replace the development server with Starman
66              
67             =head1 SYNOPSIS
68              
69             myapp_server.pl [options]
70              
71             -d --debug force debug mode
72             -f --fork handle each request in a new process
73             (defaults to false)
74             -? --help display this help and exits
75             -h --host host (defaults to all)
76             -p --port port (defaults to 3000)
77             --follow_symlinks follow symlinks in search directories
78             (defaults to false. this is a no-op on Win32)
79             --background run the process in the background
80             --pidfile specify filename for pid file
81             --workers Initial number of workers to spawn (defaults to 5)
82             --min_servers Minimum number of worker processes runnning
83             --min_spare_servers Minimum number of spare workers (more are forked
84             if there are less spare than this)
85             --max_spare_servers Maximum number of spare workers (workers are killed
86             if there are more spare than this)
87             --max_servers Maximum number of workers in total.
88             --max_requests Maximum number of requests each worker will handle
89             --backlog Number of backlogged connections allowed
90             --user User to run as
91             --group Group to run as
92              
93             See also:
94             perldoc Starman
95             perldoc plackup
96             perldoc Catalyst::PSGI
97              
98             =head1 DESCRIPTION
99              
100             A Catalyst extension to replace the development server with L<Starman>.
101              
102             This module replaces the functionality of L<Catalyst::Engine::HTTP::Prefork>,
103             which is now deprecated.
104              
105             It provides access to the prefork engine specific options which were previously
106             added by hacking your server script.
107              
108             =head1 Adding this to your application
109              
110             Just add a server script module to your application which inherits from this
111             package.
112              
113             L<Catalyst::ScriptRunner> will automatically detect and use it when
114             script/myapp_server.pl is started.
115              
116             For example:
117              
118             package MyApp::Script::Server;
119             use Moose;
120             use namespace::autoclean;
121              
122             extends 'CatalystX::Script::Server::Starman';
123              
124             1;
125              
126             =head1 SEE ALSO
127              
128             L<plackup> - can be used to start your application C<.psgi> under Starman
129              
130             L<Catalyst::PSGI>
131              
132             =head1 AUTHOR
133              
134             Tomas Doran (t0m) C<< <bobtfish@bobtfish.net> >>
135              
136             =head1 COPYRIGHT & LICENSE
137              
138             Copyright 2009 the above author(s).
139              
140             This sofware is free software, and is licensed under the same terms as perl itself.
141              
142             =cut
143