From: Steinar H. Gunderson Date: Sun, 11 Feb 2024 19:52:49 +0000 (+0100) Subject: If reconnect fails, don't kill the entire script. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=42e66ba5d0de97c67ad1950284dc73d14eeeb3e2;p=skvidarsync If reconnect fails, don't kill the entire script. The intention was indeed to try again, but RaiseError on DBI->connect() evidently also raises error on connection failure. --- diff --git a/bin/sync.pl b/bin/sync.pl index b725b6e..756f86a 100644 --- a/bin/sync.pl +++ b/bin/sync.pl @@ -845,7 +845,9 @@ if ($#ARGV >= 0 && $ARGV[0] eq '--daemon') { while (!defined($dbh) || !$dbh->ping) { print STDERR "Database connection lost, reconnecting...\n"; sleep 1; - $dbh = db_connect(); + eval { + $dbh = db_connect(); + }; } my $s = IO::Select->new($dbh->{pg_socket}); my @ready = $s->can_read(150.0); # slack.com HTTP timeout is ~3 minutes, sheets.googleapis.com is ~4 minutes.