[freeside-commits] branch FREESIDE_3_BRANCH updated. 6e290a36fd1ccfbd8e551f21ff8aa51bdfa40bec
Christopher Burger
burgerc at freeside.biz
Tue Mar 13 08:05:43 PDT 2018
The branch, FREESIDE_3_BRANCH has been updated
via 6e290a36fd1ccfbd8e551f21ff8aa51bdfa40bec (commit)
from 7d0e42b9cf20e333c9cdfdfe1d4071483ed0aa5e (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 6e290a36fd1ccfbd8e551f21ff8aa51bdfa40bec
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