Make pandora_db read ha_hosts_file if available.

This commit is contained in:
Ramon Novoa 2023-03-21 19:24:52 +01:00
parent 1eae8a5a4d
commit 373701e28a
1 changed files with 14 additions and 0 deletions

View File

@ -629,6 +629,20 @@ sub pandora_load_config_pdb ($) {
$conf->{'errorlogfile'} = $conf->{'errorlog_file'};
$conf->{'errorlogfile'} = "/var/log/pandora_server.error" unless defined ($conf->{'errorlogfile'});
# The DB host was overridden by pandora_ha.
if (defined($conf->{'ha_hosts_file'}) && -f $conf->{'ha_hosts_file'}) {
eval {
open(my $fh, '<', $conf->{'ha_hosts_file'}) or return;
my $dbhost = <$fh>;
chomp($dbhost);
if (defined($dbhost) && $dbhost ne '') {
$conf->{'dbhost'} = $dbhost;
}
close($fh);
};
}
print " [*] DB Host is " . $conf->{'dbhost'} . "\n";
# Read additional tokens from the DB
my $dbh = db_connect ($conf->{'dbengine'}, $conf->{'dbname'}, $conf->{'dbhost'}, $conf->{'dbport'}, $conf->{'dbuser'}, $conf->{'dbpass'});