Initial idea to reconnect if needed

This commit is contained in:
2025-05-27 01:25:36 +02:00
parent 7667819687
commit e0bab3a7b4
2 changed files with 25 additions and 0 deletions

View File

@@ -120,6 +120,30 @@ sub get_fetcher_module {
}
}
sub db_connect {
my $self = shift;
if ($self->{'config'}->{'fetchers'}->{'db'}->{'dbh'}) {
#We pretend to be connected
if ($self->{'config'}->{'fetchers'}->{'db'}->{'dbh'}->ping()) {
#We can ping, all is good
return 1;
} else {
#No can ping, time to reconnect
if ($self->{'config'}->{'fetchers'}->{'db'}->connect()) {
#all good
return 1;
} else {
#can't connect??
die "Can't connect to db";
}
}
} else {
#Never connected?
$self->{'config'}->{'fetchers'}->{'db'}->init();
}
return 0;
}
sub get_dbh {
my $self = shift;
my $dbh = $self->{'config'}->{'fetchers'}->{'db'}->{'dbh'};