[freeside-commits] branch master updated. e46f0ef0da8d0f639bacb293bfdf820e2a68b480

Christopher Burger burgerc at freeside.biz
Tue Mar 13 07:20:30 PDT 2018


The branch, master has been updated
       via  e46f0ef0da8d0f639bacb293bfdf820e2a68b480 (commit)
      from  d41661cfbdcf4147342c83d3ed992f706abb92da (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e46f0ef0da8d0f639bacb293bfdf820e2a68b480
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue Mar 13 10:20:06 2018 -0400

    RT# 79780 - added a 60 second pause when there is a connection failure, then retry.  Do this for 20 hours

diff --git a/FS/bin/freeside-ipifony-download b/FS/bin/freeside-ipifony-download
index 10faa7483..09e83ea10 100644
--- a/FS/bin/freeside-ipifony-download
+++ b/FS/bin/freeside-ipifony-download
@@ -104,16 +104,7 @@ if ( $opt{P} =~ /^(\d+)$/ ) {
 }
 
 # for now assume SFTP download as the only method
-print STDERR "Connecting to $sftpuser\@$host...\n" if $opt{v};
-
-my $sftp = Net::SFTP::Foreign->new(
-  host      => $host,
-  user      => $sftpuser,
-  port      => $port,
-  # for now we don't support passwords. use authorized_keys.
-  timeout   => 30,
-  #more      => ($opt{v} ? '-v' : ''),
-);
+my $sftp = sftp_connect($host, $sftpuser, $port);
 die "failed to connect to '$sftpuser\@$host'\n(".$sftp->error.")\n"
   if $sftp->error;
 
@@ -289,6 +280,33 @@ Finished!
 ";
 }
 
+sub sftp_connect {
+  my ($host, $sftpuser, $port) = @_;
+  my $sftp;
+  my $connection_tries = 1;
+
+  while (1) {
+      print STDERR "Connecting to $sftpuser\@$host try number $connection_tries...\n" if $opt{v};
+      $sftp = Net::SFTP::Foreign->new(
+        host      => $host,
+        user      => $sftpuser,
+        port      => $port,
+        # for now we don't support passwords. use authorized_keys.
+        timeout   => 30,
+        #more      => ($opt{v} ? '-v' : ''),
+      );
+
+      if ($sftp->error && $connection_tries < 1200) {
+        $connection_tries++;
+        print STDERR "Connection failed to $sftpuser\@$host trying again in 60 sec...\n" if $opt{v};
+        sleep 60;
+      }
+      else { last; }
+  }
+
+  return $sftp
+}
+
 =head1 NAME
 
 freeside-ipifony-download - Download and import invoice items from IPifony.

-----------------------------------------------------------------------

Summary of changes:
 FS/bin/freeside-ipifony-download | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)




More information about the freeside-commits mailing list