Skip to content

Commit

Permalink
introduce an sftp timeout configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed May 1, 2023
1 parent 1aa87cf commit 37009fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion backend/model/marc_ao_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions backend/plugin_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 37009fe

Please sign in to comment.