Initial idea to reconnect if needed
This commit is contained in:
@@ -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'};
|
||||
|
||||
Reference in New Issue
Block a user