App-ForExample
view release on metacpan or search on metacpan
lib/App/ForExample.pm view on Meta::CPAN
--base The base for your application, default: / (At the root)
--hostname The hostname from which your application is served (e.g. example.com)
monit
Generate a basic, stripped-down monit configuration suitable for a non-root user
--home The directory designated monit home (containing the pid file, log, rc, ...)
For example:
for-example catalyst/fastcgi apache2 standalone --class My::App --hostname example.com
for-example monit --home \$HOME/my-monit
for-example catalyst/mod_perl --class Project::Xyzzy --hostname xyzzy.com --home Project-Xyzzy
_END_
}
start [qw/ help|h|? /], sub {
my $ctx = shift;
if ( $ctx->option( 'help' ) || $ctx->last ) {
do_help $ctx;
exit 0;
}
};
rewrite qr#catalyst/(?:mod_perl[12]|modperl[12]?)# => 'catalyst/mod_perl';
on 'catalyst/mod_perl *' =>
[ qw/ output=s /, @parse_catalyst ] => sub {
my $ctx = shift;
my ($server);
for ( @_ ) {
m/(apache2?)/ and ($server) = ($1) or
croak "Don't understand argument $_ (@_)";
}
($server) = qw/apache2/;
my @data;
my $catalyst_data = parse_catalyst $ctx;
push @data, %$catalyst_data;
if ( $server =~ m/^apache2?$/ ) {
output( $ctx, 'catalyst-mod_perl' => process 'catalyst/mod_perl/apache2' => @data );
}
else {
croak "Don't understand server \"$server\""
}
};
on 'catalyst/fastcgi *' =>
[ @parse_catalyst, qw/ bare output=s /] => sub {
my $ctx = shift;
my ($server, $server_module, $mode);
for ( @_ ) {
m/(apache2?)(?:=(?:mod_)?(fastcgi|fcgid))?/ and ($server, $server_module) = ($1, $2) or
m/lighttpd/ and $server = 'lighttpd' or
m/nginx/ and $server = 'nginx' or
m/(monit|start-stop)/ and $server = $1 or # Not really a server, but...
m/standalone/ and $mode = 'standalone' or
m/static/ and $mode = 'static' or
m/dynamic/ and $mode = 'dynamic' or
croak "Don't understand argument $_ (@_)";
}
($server, $server_module) = qw/apache2 fastcgi/ unless $server;
($mode) = qw/standalone/ unless $mode;
my @data;
my $bare = $ctx->option( 'bare' );
my $catalyst_data = parse_catalyst $ctx;
push @data, %$catalyst_data;
my $name = $catalyst_data->{name};
if ( $server =~ m/^apache2?$/ ) {
if ( $mode eq 'standalone' ) {
# TODO Error in Catalyst::Engine::FastCGI dox?
my @output;
push @output, 'catalyst-fastcgi.apache2' => process 'catalyst/fastcgi/apache2/standalone' => @data;
unless ($bare) {
push @output, 'start-stop' => process 'catalyst/fastcgi/start-stop' => @data;
push @output, 'monit' => process 'catalyst/fastcgi/monit' => @data;
}
output( $ctx, @output );
}
elsif ( $mode eq 'dynamic' ) {
output( $ctx, 'catalyst-fastcgi.apache2' => process 'catalyst/fastcgi/apache2/dynamic' => @data );
}
elsif ( $mode eq 'static' ) {
output( $ctx, 'catalyst-fastcgi.apache2' => process 'catalyst/fastcgi/apache2/static' => @data );
}
else {
croak "Don't understand mode \"$mode\""
}
}
elsif ( $server eq 'lighttpd' ) {
if ( $mode eq 'standalone' ) {
my @output;
push @output, 'catalyst-fastcgi.lighttpd' => process 'catalyst/fastcgi/lighttpd/standalone' => @data;
unless ($bare) {
push @output, 'start-stop' => process 'catalyst/fastcgi/start-stop' => @data;
push @output, 'monit' => process 'catalyst/fastcgi/monit' => @data;
}
output( $ctx, @output );
}
elsif ( $mode eq 'static' ) {
output( $ctx, 'catalyst-fastcgi.lighttpd' => process 'catalyst/fastcgi/lighttpd/static' => @data );
}
else {
croak "Don't understand mode \"$mode\""
( run in 1.320 second using v1.01-cache-2.11-cpan-5735350b133 )