Skip to content

Commit

Permalink
Fixed autodie on exceptions and moved maintenance.pl to asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
reyjrar committed Apr 18, 2011
1 parent 094d53e commit 3e28695
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion script/analyzer.pl
Expand Up @@ -47,7 +47,8 @@ sub POE::Kernel::TRACE_DEFAULT () { 0 }
my $CFG = YAML::LoadFile( $configFile ) or die "unable to load $configFile: $!\n";

# Connect to the Database:
my $dbConn = DBIx::Connector->new( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass} );
my $dbConn = DBIx::Connector->new( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass},
{ RaiseError => 0 } );

#------------------------------------------------------------------------#
# POE Environment Setup
Expand Down
17 changes: 10 additions & 7 deletions script/maintenance.pl
Expand Up @@ -4,11 +4,12 @@
#
# Code by Brad Lhotsky <brad@divisionbyzero.net>
#

$|++;
use strict;
use warnings;
use FindBin;
use DBIx::Connector;
use DBI;
use DBD::Pg qw(:async);
use Try::Tiny;
use Getopt::Std;

Expand Down Expand Up @@ -41,7 +42,7 @@
my $CFG = YAML::LoadFile( $configFile ) or die "unable to load $configFile: $!\n";

# Connect to the Database:
my $dbConn = DBIx::Connector->new( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass} );
my $dbh = DBI->connect( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass} );

# Find all the plugins with keep_for set
foreach my $plugin (sort keys %{ $CFG->{plugins} } ) {
Expand All @@ -66,16 +67,18 @@
# Prepare the Clean Up
my $sql = qq{ select ${prefix}_cleanup( ? ) };
print "preparing '$sql' with arg '$keep_for' .." unless $OPT{q};
my $sth = $dbConn->run( fixup => sub {
my $sth = $_->prepare( $sql );
$sth;
});
my $sth = $dbh->prepare( $sql, {pg_async => PG_ASYNC} );

try {
$sth->execute( $keep_for );
} catch {
print "error cleaning up: ($_)" unless $OPT{q};
};

while ( ! $sth->pg_ready() ) {
sleep 2;
print '.';
}

print " done.\n" unless $OPT{q};
}
3 changes: 2 additions & 1 deletion script/sniffer.pl
Expand Up @@ -51,7 +51,8 @@ sub POE::Kernel::ASSERT_DEFAULT () { 1 }
my $CFG = YAML::LoadFile( $configFile ) or die "unable to load $configFile: $!\n";

# Connect to the Database:
my $dbConn = DBIx::Connector->new( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass} );
my $dbConn = DBIx::Connector->new( $CFG->{db}{dsn}, $CFG->{db}{user}, $CFG->{db}{pass},
{ RaiseError => 0 } );

#------------------------------------------------------------------------#
# POE Environment Setup
Expand Down

0 comments on commit 3e28695

Please sign in to comment.