Apache-SiteConfig

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Apache::SiteConfig

0.03    一  7/25 17:37:17 2011
        - Provide su, chown attributes
        - Add httpd.conf detection

0.01    Sun Jul 24 00:53:16 2011
        - original version

lib/Apache/SiteConfig/Deploy.pm  view on Meta::CPAN

    $Single->{args} = {};
    $Single->{tasks} = {};

    # built-in tasks
    $Single->{tasks}->{deploy} = sub { $Single->deploy( @_ ); };
    $Single->{tasks}->{update} = sub { $Single->update( @_ ); };
    $Single->{tasks}->{clean}  = sub { $Single->clean( @_ ); };

    # setup accessors to main::
    no strict 'refs';
    for my $key ( qw(su chown name domain domain_alias webroot source deploy task) ) {
        *{ 'main::' . $key } = sub { 
            ${ $class .'::'}{ $key }->( $Single , @_ );
        };
    }

    # Exporter->import( @_ );
    return 1;
}

sub new { bless {} , shift; }

lib/Apache/SiteConfig/Deploy.pm  view on Meta::CPAN

    }

    say $cmd;
    if( $abort_on_failure ) {
        system( $cmd ) == 0 or die $!;
    } else {
        system( $cmd );
    }
}

sub chown {
    my $self = shift;
    $self->{args}->{chown} = $_[0];
}

sub su {
    my $self = shift;
    $self->{args}->{su} = $_[0];
}

sub name ($) { 
    my $self = shift;
    $self->{args}->{name} = $_[0];

lib/Apache/SiteConfig/Deploy.pm  view on Meta::CPAN

            last SKIP_SOURCE_CLONE if -e File::Spec->join( $args->{site_dir} , '.git' );

            say "Cloning hg repository from $args->{source}->{hg} to $args->{site_dir}";
            $self->execute_command("hg clone $args->{source}->{hg} $args->{site_dir}") == 0 or die($?);
        }

    }

    $self->prepare_log_path( $args );

    if( $args->{chown} ) {
        say "Changing owner to $args->{site_dir}";
        $self->execute_command( sprintf( 'chown -R %s: ' , $args->{site_dir} ) ,1);
    }
    


    # Default template
    my $template = Apache::SiteConfig::Template->new;  # apache site config template
    my $context = $template->build( 
        ServerName => $args->{domain},
        ServerAlias => $args->{domain_alias},
        DocumentRoot => $args->{document_root},

lib/Apache/SiteConfig/Deploy.pm  view on Meta::CPAN

    use Apache::SiteConfig::Deploy;

    name   'projectA';

    domain 'foo.com';

    domain_alias 'foo.com';


    su 'www-data';
    chown 'www-data';

    source git => 'git@git.foo.com:projectA.git';

    source 
        git => 'git@git.foo.com:projectA.git',
        branch => 'master';

    source hg  => 'http://.........';




( run in 3.571 seconds using v1.01-cache-2.11-cpan-71847e10f99 )