db_sucker 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5629ff79f3a0b48bf58f3a19c3f3f342082d76ae896ffca04d781e19de8959d
4
- data.tar.gz: 0601cd98271331cd62ffbda5f7ae0c6ecd27333bad3598229b224d5bceef586b
3
+ metadata.gz: b8074c1cae68f9c791d50bb5494ff86eb51bb840470bd2bf94d72cebbc2822a5
4
+ data.tar.gz: 8fbfadaf58d757f5bc626e23288c0056ffe4eaf1db470718784ad25c3403db3c
5
5
  SHA512:
6
- metadata.gz: 2f856a743e274a0a4caf46aa614268d14e92ea40f63cc60f248d7561ddc421c260ddec37542b5a1095e8f6b1b654e8afc4616dd8191170251a48d67ba40645cf
7
- data.tar.gz: 3a633a3ca67f10b3f0914b8a4b5c7fa6355d4b471a94dab1b8423135919b6b183b4accce904b2a350394e17601715dfa24410f43873e79cc839dd0367bfe3a55
6
+ metadata.gz: 6f5784e1d45ed9878c412de70ba0a1d3a243a38c1c6528c790a9aba1dadfcd74b223792b8060647ecf660e0703bb21da0110421c0581c6984127264129246506
7
+ data.tar.gz: 4ad5f0a6e3bc1466eb6e92de0d39eab511435fd06510c6e60380f9ac6b3a8eec7cc3458b18dbb73787b290f2949726897fc4feefd2918464cc48db1f4ecb42dd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 3.2.0
2
+
3
+ ### Updates
4
+
5
+ * Added support for native sftp command line utility (see application option `file_transport`) but it
6
+ only works with non-interactive key authentication.
7
+
8
+ ### Fixes
9
+
10
+ * Prevent application from crashing when eval produces non-StandardErrors (e.g. SyntaxErrors)
11
+
12
+ -------------------
13
+
1
14
  ## 3.1.1
2
15
 
3
16
  ### Fixes
data/README.md CHANGED
@@ -130,7 +130,7 @@ To get a list of available interface options and shortcuts press `?` or type `:h
130
130
 
131
131
  ## Configuration (application) - Ruby format
132
132
 
133
- DbSucker has a lot of settings and other mechanisms which you can tweak and utilize by creating a `~/.db_sucker/config.rb` file. You can change settings, add hooks or define own actions. For more information please take a look at the [documented example config](https://github.com/2called-chaos/db_sucker/blob/master/doc/config_example.rb) and/or [complete list of all settings](https://github.com/2called-chaos/db_sucker/blob/master/lib/db_sucker/application.rb#L58-L129).
133
+ DbSucker has a lot of settings and other mechanisms which you can tweak and utilize by creating a `~/.db_sucker/config.rb` file. You can change settings, add hooks or define own actions. For more information please take a look at the [documented example config](https://github.com/2called-chaos/db_sucker/blob/master/doc/config_example.rb) and/or [complete list of all settings](https://github.com/2called-chaos/db_sucker/blob/master/lib/db_sucker/application.rb#L60-L134).
134
134
 
135
135
 
136
136
  ## Deferred import
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.2.0
@@ -14,6 +14,10 @@ opts[:deferred_threshold] = 50_000_000 # 50 MB
14
14
  opts[:status_format] = :full # used for IO operations, can be one of: none, minimal, full
15
15
  opts[:pv_enabled] = true # disable pv utility autodiscovery (force non-usage)
16
16
 
17
+ # Use native SFTP command for way faster transfer rates, only use with non-interactive key authentication!
18
+ opts[:file_transport] = :ruby
19
+ #opts[:file_transport] = :native
20
+
17
21
  # used to open core dumps (should be a blocking call, e.g. `subl -w' or `mate -w')
18
22
  # MUST be windowed! vim, nano, etc. will not work!
19
23
  opts[:core_dump_editor] = "subl -w"
@@ -15,6 +15,12 @@ module DbSucker
15
15
  end
16
16
  end
17
17
 
18
+ def sftp_native_download *args, &block
19
+ IO::SftpNativeDownload.new(self, *args).tap do |op|
20
+ block.try(:call, op)
21
+ end
22
+ end
23
+
18
24
  def file_copy *args, &block
19
25
  IO::FileCopy.new(self, *args).tap do |op|
20
26
  block.try(:call, op)
@@ -0,0 +1,79 @@
1
+ module DbSucker
2
+ class Application
3
+ class SklavenTreiber
4
+ class Worker
5
+ module IO
6
+ class SftpNativeDownload < Base
7
+ UnknownEventError = Class.new(::RuntimeError)
8
+ attr_reader :downloader
9
+
10
+ def init
11
+ @label = "downloading"
12
+ @entity = "download"
13
+ @throughput.categories << :inet << :inet_down
14
+ end
15
+
16
+ def reset_state
17
+ super
18
+ @downloader = nil
19
+ end
20
+
21
+ def build_sftp_command src, dst
22
+ [].tap{|cmd|
23
+ cmd << %{sftp}
24
+ cmd << %{-P #{@ctn.source["ssh"]["port"]}} if @ctn.source["ssh"]["port"]
25
+ @ctn.ssh_key_files.each {|f| cmd << %{-i "#{f}"} }
26
+ cmd << %{"#{@ctn.source["ssh"]["username"]}@#{@ctn.source["ssh"]["hostname"]}:#{src}"}
27
+ cmd << %{"#{dst}"}
28
+ }.join(" ").strip
29
+ end
30
+
31
+ def download! opts = {}
32
+ opts = opts.reverse_merge(tries: 3, read_size: @read_size, force_new_connection: true)
33
+ cmd = build_sftp_command(@remote, @local)
34
+ prepare_local_destination
35
+
36
+ execute(opts.slice(:tries).merge(sleep_error: 3)) do
37
+ begin
38
+ @state = :init
39
+ @ctn.sftp_start(opts[:force_new_connection]) do |sftp|
40
+ @filesize = sftp.lstat!(@remote).size
41
+ end
42
+
43
+ # status thread
44
+ status_thread = @worker.app.spawn_thread(:sklaventreiber_worker_ctrl) do |thr|
45
+ loop do
46
+ @offset = File.size(@local) if File.exist?(@local)
47
+ break if thr[:stop]
48
+ thr.wait(0.25)
49
+ end
50
+ end
51
+
52
+ @state = :downloading
53
+ debug "Opening process `#{cmd}'"
54
+ Open3.popen2e(cmd, pgroup: true) do |_stdin, _stdouterr, _thread|
55
+ # close & exit status
56
+ _stdin.close_write
57
+ exit_status = _thread.value
58
+ if exit_status == 0
59
+ debug "Process exited (#{exit_status}) `#{cmd}'"
60
+ else
61
+ warning "Process exited (#{exit_status}) `#{cmd}'"
62
+ end
63
+ end
64
+
65
+ status_thread[:stop] = true
66
+ status_thread.signal
67
+ status_thread.join
68
+ ensure
69
+ @state = :finishing
70
+ end
71
+ end
72
+ @state = :done
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -142,11 +142,23 @@ module DbSucker
142
142
  @local_file_compressed = local_tmp_file(File.basename(@remote_file_compressed))
143
143
  @local_files_to_remove << @local_file_compressed
144
144
 
145
- sftp_download(@ctn, @remote_file_compressed => @local_file_compressed) do |dl|
146
- dl.status_format = app.opts[:status_format]
147
- @status = [dl, "yellow"]
148
- dl.abort_if { @should_cancel }
149
- dl.download!
145
+ case app.opts[:file_transport]
146
+ when :ruby
147
+ sftp_download(@ctn, @remote_file_compressed => @local_file_compressed) do |dl|
148
+ dl.status_format = app.opts[:status_format]
149
+ @status = [dl, "yellow"]
150
+ dl.abort_if { @should_cancel }
151
+ dl.download!
152
+ end
153
+ when :native
154
+ sftp_native_download(@ctn, @remote_file_compressed => @local_file_compressed) do |dl|
155
+ dl.status_format = app.opts[:status_format]
156
+ @status = [dl, "yellow"]
157
+ dl.abort_if { @should_cancel }
158
+ dl.download!
159
+ end
160
+ else
161
+ raise UnknownFileTransportError, "Unknown file transport `#{app.opts[:file_transport]}' configured, valid are `ruby' and `native'!"
150
162
  end
151
163
  end
152
164
 
@@ -4,6 +4,7 @@ module DbSucker
4
4
  class Worker
5
5
  SlotPoolNotInitializedError = Class.new(::RuntimeError)
6
6
  ChannelFailRetryError = Class.new(::RuntimeError)
7
+ UnknownFileTransportError = Class.new(::RuntimeError)
7
8
 
8
9
  include Core
9
10
  include Accessors
@@ -72,7 +72,7 @@ module DbSucker
72
72
  begin
73
73
  f.puts("#{evil}\n\n")
74
74
  f.puts(app.sync{ app.instance_eval(evil) })
75
- rescue StandardError => ex
75
+ rescue Exception => ex
76
76
  f.puts("#{ex.class}: #{ex.message}")
77
77
  ex.backtrace.each {|l| f.puts(" #{l}") }
78
78
  end
@@ -77,6 +77,12 @@ module DbSucker
77
77
  status_format: :full, # used for IO operations, can be one of: none, minimal, full
78
78
  pv_enabled: true, # disable pv utility autodiscovery (force non-usage)
79
79
 
80
+ # file transport: how to copy files from the remote
81
+ # ruby Use ruby sftp-library (why slow?)
82
+ # native Shell out to native sftp command (we try our best to build the command according to your SSH settings)
83
+ # NOTE: only use with non-interactive key authentication
84
+ file_transport: :ruby,
85
+
80
86
  # sklaven treiber
81
87
  window_enabled: true, # if disabled effectively disables any status progress or window drawing
82
88
  window_draw: true, # wether to refresh screen or not
@@ -1,4 +1,4 @@
1
1
  module DbSucker
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  UPDATE_URL = "https://raw.githubusercontent.com/2called-chaos/db_sucker/master/VERSION"
4
4
  end
data/lib/db_sucker.rb CHANGED
@@ -32,6 +32,7 @@ require "db_sucker/application/sklaven_treiber/log_spool"
32
32
  require "db_sucker/application/sklaven_treiber/worker/io/base"
33
33
  require "db_sucker/application/sklaven_treiber/worker/io/throughput"
34
34
  require "db_sucker/application/sklaven_treiber/worker/io/sftp_download"
35
+ require "db_sucker/application/sklaven_treiber/worker/io/sftp_native_download"
35
36
  require "db_sucker/application/sklaven_treiber/worker/io/file_copy"
36
37
  require "db_sucker/application/sklaven_treiber/worker/io/file_gunzip"
37
38
  require "db_sucker/application/sklaven_treiber/worker/io/file_shasum"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_sucker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Pachnit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -175,6 +175,7 @@ files:
175
175
  - lib/db_sucker/application/sklaven_treiber/worker/io/file_shasum.rb
176
176
  - lib/db_sucker/application/sklaven_treiber/worker/io/pv_wrapper.rb
177
177
  - lib/db_sucker/application/sklaven_treiber/worker/io/sftp_download.rb
178
+ - lib/db_sucker/application/sklaven_treiber/worker/io/sftp_native_download.rb
178
179
  - lib/db_sucker/application/sklaven_treiber/worker/io/throughput.rb
179
180
  - lib/db_sucker/application/sklaven_treiber/worker/routines.rb
180
181
  - lib/db_sucker/application/slot_pool.rb