tbrehm
2010-05-20 ca24ab748989a3be99639878c9e26acf5e3f2951
Added better error handling to vlogger script in case that the mysql database connection is not available.
1 files modified
18 ■■■■ changed files
server/scripts/vlogger 18 ●●●● patch | view | raw | blame | history
server/scripts/vlogger
@@ -252,9 +252,14 @@
    }
    # test the connection
    my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS )
      or die "DBI Error: $!";
    $dbh->disconnect;
    eval {
      my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS )
        or die "DBI Error: $!";
      $dbh->disconnect;
    };
    if ($@) {
       print "MySQL Connection problem\n";
    }
    # SIGALRM dumps the tracker hash
    $SIG{ALRM} = \&dump_tracker;
@@ -503,7 +508,8 @@
# sub to update the database with the tracker data
sub dump_tracker {
    if ( keys(%tracker) > 0 ) {
    eval {
    if ( keys(%tracker) > 0 ) {
        my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS )
          or warn "DBI Error: $!";
        foreach my $key ( keys(%tracker) ) {
@@ -529,6 +535,10 @@
        %tracker = ();
    }
    alarm $DBI_DUMP;
    };
    if ($@) {
        print "Unable to store vlogger data in database\n";
    }
}
# print usage info