Activator

 view release on metacpan or  search on metacpan

bin/activator.pl  view on Meta::CPAN


    my $cmd;

    if ( $httpd_pid && $httpd_pid =~ /^\d+$/ ) {
	INFO("killing pid '$httpd_pid' from pid file");
	system( "kill $httpd_pid");
    } else {
	INFO("Looking for pid from ps");
	$cmd = qq(ps -C httpd -opid,user,command | grep '$ENV{USER}' | grep '$project');
	INFO( $cmd );

	my @outp = split /\n/, `$cmd`;
	my @pids;
	foreach my $line ( @outp ) {
	    $line =~ /^\s*(\d+)\s/;
	    push @pids, $1 if $1;
	}
	if ( @pids ) {
	    INFO("Killing from ps");
	    $cmd = 'kill ' . join ' ', @pids;
	    DEBUG( $cmd );
	    system( $cmd );
	} else {
	    INFO("Nothing to kill: can't find any 'httpd's running");
	}
    }

    INFO("Sleeping to allow children to exit");
    $| = 1;
    foreach ( 1..3 ) {
	print ".";
	sleep(1);
    }
    print "\n";
    $cmd = "/usr/sbin/httpd -f $httpd_conf";
    INFO("Starting apache");
    DEBUG("...with command: $cmd");
    system( $cmd );

}

# TODO: this should process anything, not just apache2 files
sub process {
    my $dir  = $File::Find::dir; # is the current directory name,
    my $file = $_;               # is the current filename within that directory
    my $fq   = $File::Find::name; # is the complete pathname to the file.

    # capture the intervening path
    $fq =~ m|share/apache2/(.+)\.tt$|;
    my $out = $1;
    return unless $out;

    DEBUG( qq( processing $file into ).$config->{apache2}->{ServerRoot}.'/'.$out );
    my $tt = Template->new( { DEBUG => 1,
			      ABSOLUTE => 1,
			      OUTPUT_PATH  => $config->{apache2}->{ServerRoot},
			    }
			  );
    $tt->process( $fq, $config, $out ) || Activator::Log->logdie( $tt->error()."\n");

    # TODO: use some smart hueristics to properly chmod that which
    # should be executable
    #
    #if( $out =~ m@/s?bin/|/init.d/@ ) {
    #	chmod 0755, $config->{apache2}->{ServerRoot}.'/'.$out
    #}
}

# copy the default project config for a catalyst app to the correct
# place, setting project_name, project_alias, domain_name.
sub init {

    use Cwd;
    DEBUG( getcwd );


}



( run in 1.883 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )