Skip to content

Instantly share code, notes, and snippets.

@creativetechnologist
Created September 18, 2014 09:24
Show Gist options
  • Save creativetechnologist/ab94c3d5ce65b42bb43c to your computer and use it in GitHub Desktop.
Save creativetechnologist/ab94c3d5ce65b42bb43c to your computer and use it in GitHub Desktop.
JDW SFTP
ftpupload.how_many_retries.times do
begin
Net::SFTP.start(ftpupload.host, ftpupload.username) do |sftp|
sftp.upload!(filename, "/")
AdminMailer.notifyadmins("Succesfully sent File to JDW","Sent File to JDW: #{filename}").deliver
puts "sent file up"
end
break
rescue Exception=>e
# Error
AdminMailer.notifyadmins("Error Sending File to JDW","#{e}. Will retry in #{ftpupload.seconds_sleep_between_retries} seconds. #{filename}").deliver
puts "\tCaught: #{e} waiting to retry"
sleep ftpupload.seconds_sleep_between_retries
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment