diff --git a/README.md b/README.md index a309116..405038d 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Sample configuration: AppConfig[:marcao_sftp_user] = 'a_user' AppConfig[:marcao_sftp_password] = 'secret password' AppConfig[:marcao_sftp_path] = '/remote/path' + AppConfig[:marcao_sftp_timeout] = 30 ``` ### marcao_schedule @@ -86,6 +87,9 @@ The password to authenticate with on the SFTP server. ### marcao_sftp_path The path on the SFTP server to upload the exported records to. +### marcao_sftp_timeout +Timeout in seconds to use when connecting to the SFTP server (default 30). + ## Report diff --git a/backend/model/marc_ao_exporter.rb b/backend/model/marc_ao_exporter.rb index 25ba156..ebfe66a 100644 --- a/backend/model/marc_ao_exporter.rb +++ b/backend/model/marc_ao_exporter.rb @@ -45,7 +45,8 @@ def self.run Log.info("marcao: Retrying SFTP upload (retry number #{retry_count})") end - Net::SFTP.start(AppConfig[:marcao_sftp_host], AppConfig[:marcao_sftp_user], { password: AppConfig[:marcao_sftp_password] }) do |sftp| + Net::SFTP.start(AppConfig[:marcao_sftp_host], AppConfig[:marcao_sftp_user], + { password: AppConfig[:marcao_sftp_password], timeout: AppConfig[:marcao_sftp_timeout] }) do |sftp| sftp.upload!(export_file_path, File.join(AppConfig[:marcao_sftp_path], File.basename(export_file_path))) end break diff --git a/backend/plugin_init.rb b/backend/plugin_init.rb index 7da7233..aaba466 100644 --- a/backend/plugin_init.rb +++ b/backend/plugin_init.rb @@ -12,6 +12,13 @@ AppConfig.has_key?(:marcao_sftp_user) && AppConfig.has_key?(:marcao_sftp_password) && AppConfig.has_key?(:marcao_sftp_path) + if AppConfig.has_key?(:marcao_sftp_timeout) + unless AppConfig[:marcao_sftp_timeout].is_a?(Integer) + raise "marcao plugin configuration error: AppConfig[:marcao_sftp_timeout] must be an integer." + end + else + AppConfig[:marcao_sftp_timeout] = 30 + end AppConfig[:marcao_sftp_enabled] = true else AppConfig[:marcao_sftp_enabled] = false