]> git.sesse.net Git - skvidarsync/commitdiff
If reconnect fails, don't kill the entire script.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Feb 2024 19:52:49 +0000 (20:52 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Feb 2024 19:52:49 +0000 (20:52 +0100)
The intention was indeed to try again, but RaiseError on DBI->connect()
evidently also raises error on connection failure.

bin/sync.pl

index b725b6ef383948c599a9dde60382528fcd4cfef3..756f86a92d4e7f15139a46ba8c66945a5dcbf90a 100644 (file)
@@ -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.