Activator
view release on metacpan or search on metacpan
bin/activator.pl view on Meta::CPAN
See L<Activator::Tutorial> for a description of how to configure an Activator project.
=cut
# $config, $args, $project, $action and the current apache pid are globally interesting
my ( $config, $args, $project, $action, $httpd_pid );
try eval {
# Act::Config requires that project be set via an option or be the
# last arg, hence the flag after undef below
$config = Activator::Config->get_config( \@ARGV, undef, 1 );
};
if ( catch my $e ) {
die( "Error while processing command line options: $e" );
}
my $log_level = $config->{log_level} || 'WARN';
if ( $config->{v} || $config->{verbose} ) {
Activator::Log->level( 'INFO' );
bin/activator.pl view on Meta::CPAN
$httpd_pid = `$cmd`;
chomp $httpd_pid;
}
# convenience vars
my $project_codebase = $config->{project_codebase};
my $perl5lib = $config->{apache2}->{PERL5LIB};
my $document_root = $config->{apache2}->{DocumentRoot};
my $server_root = $config->{apache2}->{ServerRoot};
my $rsync_flags = ( $config->{debug} ? '-v' : '' );
$rsync_flags .= ' --cvs-exclude';
# these commands need to run to create the target installation
my @cmds = (
# blow away the target dir
"rm -rf $config->{sync_target}",
"mkdir -p $config->{sync_target}",
"mkdir -p $config->{sync_run_dir}",
"mkdir -p $config->{sync_lock_dir}",
"mkdir -p $config->{sync_conf_dir}",
"mkdir -p $config->{sync_log_dir}",
"mkdir -p $perl5lib",
"mkdir -p $document_root",
"mkdir -p $server_root/logs",
# all your perl lib are belong to PERL5LIB
"rsync -a $rsync_flags $project_codebase/lib/* $perl5lib",
# symlink template files so we don't have to restart server
# not that this symlinks INTO document root
"ln -sf $project_codebase/root $document_root",
# symlink apache modules
"ln -sf /usr/lib/httpd/modules $server_root",
# symlink apache log files
"ln -sf $server_root/logs $config->{sync_log_dir}/httpd",
);
if ( $config->{activator_codebase} ) {
push @cmds,
"rsync -a $rsync_flags ".$config->{activator_codebase}."/lib/* $perl5lib";
}
if ( $config->{sync_data_dirs} ) {
foreach my $dir ( @{ $config->{sync_data_dirs} } ) {
push @cmds, "mkdir -p $dir";
}
}
if ( my $dict_targ = $config->{Activator}->{Dictionary}->{dict_files} ) {
push @cmds, "ln -sf $config->{conf_path}/dict $dict_targ";
bin/activator.pl view on Meta::CPAN
ABSOLUTE => 1,
OUTPUT_PATH => $config->{sync_conf_dir},
}
);
DEBUG( qq(tt processing: $fq_source_file, $config, $out ));
$tt->process( $fq_source_file, $config, $out ) || Activator::Log->logdie( $tt->error()."\n");
}
# just copy the file
else {
my $rsync_flags = ( $config->{debug} ? '-v' : '' );
$rsync_flags .= ' --cvs-exclude';
my $cmd = "rsync -a $rsync_flags $fq_source_file $fq_dest_file";
die "$cmd failed" unless !system( $cmd );
}
}
&restart();
}
sub restart {
my $httpd_conf = $config->{apache2}->{ServerRoot} . '/conf/httpd.conf';
if ( !-f $httpd_conf ) {
lib/Activator/Config.pm view on Meta::CPAN
=item *
You can pass as complex a config as you like to any script or
application, and override any scalar configuration option with your
environment variables or from the command line.
=item *
It supports realms, allowing you to have default configurations for
development, QA, production, or any number of arbitrary realms you
desire. That is, with a simple command line flag, you can switch
your configuration context.
=back
=head2 Configuration Source Precedence
The precedence heirarchy for configuration from highest to lowest is:
=over
lib/Activator/Config.pm view on Meta::CPAN
merged settings from YAML configuration files
=back
=head1 COMMAND LINE ARGUMENTS
This module allows you to override configuration file settings from
the command line. You can use long or short options using C<'-'> or
C<'--'> notation, allows barewords in any order, and recognizes the
arguments terminator C<'--'>. Also supported are multiple flag
arguments:
#### turn on super verbosity. sets $config->{v} = 2
myscript.pl -v -v
You can specify configured options at the command line for
override:
#### override the configuration file setting for 'foo'
myscript.pl --foo=bar
lib/Activator/Config.pm view on Meta::CPAN
--skip_env : ignore environment variables (EXCEPT $USER)
--project=<> : used to search for the C<E<lt>projectE<gt>.yml> file
--realm=<> : use C<E<lt>realmE<gt>.yml> in config file processing and
consider all command line arguments to be in this realm
--conf_path : colon separated list of directories to search for config files
=head2 Project as a Bareword Argument
There are times where a script takes the project name as a required
bareword argument. For these cases, require that project be the last
argument, and pass a flag to L</get_config()>.
That is, when your script is called like this:
myscript.pl --options <project>
get the config like this:
Activator::Config->get_config( \@ARGV, undef, 1 );
The second argument to L</get_config()> is the realm, so you pass
lib/Activator/Config.pm view on Meta::CPAN
}
# save these so we don't have to do it again
$self->{ARGV} = $argv;
$self->{BAREWORDS} = $barewords;
return ( $argv, $barewords );
}
# Helper to split an arg into key/value. Returns ($key, $value), where
# $value is undef if the argument is flag format (--debug), undef if
# it is a bareword ( foo ) and '--' if it is the arguments terminator
# symbol.
#
sub _get_arg {
my ( $self, $arg ) = @_;
if ( $arg !~ /^-(-)?/ ) {
return;
}
lib/Activator/Options.pm view on Meta::CPAN
# TODO: NOT YET IMPLEMENTED
Perform variable substitution
=back
=head1 COMMAND LINE ARGUMENTS
This module allows long or short options using C<'-'> or C<'--'>
notation, allows barewords in any order, and recognizes the arguments
terminator C<'--'>. Also supported are multiple flag arguments:
#### turn on super verbosity. sets $opts->{v} = 2
myscript.pl -v -v
You can specify configured options at the command line for
override:
#### override the configuration file setting for 'foo'
myscript.pl --foo=bar
lib/Activator/Options.pm view on Meta::CPAN
}
# save these so we don't have to do it again
$self->{ARGV} = $argv;
$self->{BAREWORDS} = $barewords;
return ( $argv, $barewords );
}
# Helper to split an arg into key/value. Returns ($key, $value), where
# $value is undef if the argument is flag format (--debug), undef if
# it is a bareword ( foo ) and '--' if it is the arguments terminator
# symbol.
#
sub _get_arg {
my ( $self, $arg ) = @_;
if ( $arg !~ /^-(-)?/ ) {
return;
}
lib/Activator/Registry.pm view on Meta::CPAN
$registered_something = 1;
}
if ( defined( $yaml_file ) && -f $yaml_file ) {
$self->register_file( $yaml_file );
$registered_something = 1;
}
}
else {
# refuse to reload without flag
WARN("Cowardly refusing to stomp registry without 'reload' flag");
return;
}
if ( !$registered_something ) {
my $action = 'load';
if ( keys %{ $self->{REGISTRY_BACKUP} } ) {
$self->{REGISTRY} = $self->{REGISTRY_BACKUP};
$action = 'reload';
}
share/conf/default-project.yml view on Meta::CPAN
# this is the default realm, and by default we don't define realms in this file
#
act_config_no_realms: 1
#
# default to the production realm
#
realm: production
#
# global debug flag: see perldoc Activator::Log for more specifics on debug logging.
#
debug: 1
#
# This is the name of the project, most likely the top of your perl
# namespace for a catalyst app, i.e.: MyApp
#
project_name:
#
( run in 3.836 seconds using v1.01-cache-2.11-cpan-94b05bcf43c )