--- loncom/lonsql 2001/04/02 20:16:31 1.30 +++ loncom/lonsql 2001/04/16 18:36:22 1.33 @@ -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"; @@ -71,7 +73,6 @@ while ($configline=) { chomp($ip); $hostip{$ip}=$id; - if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; } $PREFORK++; @@ -202,7 +203,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): $@"); @@ -362,6 +363,7 @@ sub reply { } } else { $answer='self_reply'; + $answer=subreply($cmd,$server); } return $answer; }