[freeside-commits] branch FREESIDE_4_BRANCH updated. 09cb31d6a1e158d149407fc8a2db02d6b1f7c978

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


The branch, FREESIDE_4_BRANCH has been updated
       via  09cb31d6a1e158d149407fc8a2db02d6b1f7c978 (commit)
      from  5bbe1f581dccf16d596eaae53414b32b772ca0a0 (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 09cb31d6a1e158d149407fc8a2db02d6b1f7c978
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