--- loncom/lonsql 2001/04/02 20:16:31 1.30 +++ loncom/lonsql 2001/04/11 20:05:29 1.31 @@ -23,18 +23,6 @@ sub wanted { push(@metalist,"$dir/$_"); } -{ - my $dbh; - unless ( - $dbh = DBI->connect("DBI:mysql:loncapa","www","123",{ RaiseError =>0,PrintError=>0}) - ) { - print "Cannot connect to database!\n"; - exit; - } - else { - $dbh->disconnect; - } -} $childmaxattempts=10; $run =0;#running counter to generate the query-id @@ -50,6 +38,20 @@ while ($configline=) { } close(CONFIG); +# ------------------------------------- Make sure that database can be accessed +{ + my $dbh; + unless ( + $dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0}) + ) { + print "Cannot connect to database!\n"; + exit; + } + else { + $dbh->disconnect; + } +} + # --------------------------------------------- Check if other instance running my $pidfile="$perlvar{'lonDaemons'}/logs/lonsql.pid"; @@ -202,7 +204,7 @@ sub make_new_child { #open database handle # making dbh global to avoid garbage collector unless ( - $dbh = DBI->connect("DBI:mysql:loncapa","www","123",{ RaiseError =>0,PrintError=>0}) + $dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0}) ) { sleep(10+int(rand(20))); &logthis("WARNING: Couldn't connect to database ($st secs): $@");