From d65d4f57d58749da096fe5097853746975cdeb6c Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Thu, 20 May 2010 10:06:11 +0000 Subject: [PATCH] Added better error handling to vlogger script in case that the mysql database connection is not available. --- server/scripts/vlogger | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/server/scripts/vlogger b/server/scripts/vlogger index d136af176c..ce0ce027bc 100755 --- a/server/scripts/vlogger +++ b/server/scripts/vlogger @@ -252,9 +252,14 @@ if ( $OPTS{'d'} ) { } # 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 open_errorlog { # 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 @@ sub dump_tracker { %tracker = (); } alarm $DBI_DUMP; + }; + if ($@) { + print "Unable to store vlogger data in database\n"; + } } # print usage info -- GitLab