dumper 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/dumper/job.rb +10 -7
  2. data/lib/dumper/version.rb +1 -1
  3. metadata +1 -1
@@ -40,7 +40,7 @@ module Dumper
40
40
  json = @agent.api_request('backup/prepare', :params => { :server_id => server[:id], :manual => server[:manual].to_s, :ext => @database.file_ext })
41
41
  abort_with('backup/prepare failed') unless json[:status] == 'ok'
42
42
 
43
- backup_id = json[:backup][:id]
43
+ @backup_id = json[:backup][:id]
44
44
 
45
45
  # Dump
46
46
  start_at = Time.now
@@ -55,9 +55,7 @@ module Dumper
55
55
  stdin.close
56
56
  rescue
57
57
  Process.kill(:INT, pid) rescue SystemCallError
58
- @database.finalize
59
- @agent.api_request('backup/fail', :params => { :backup_id => backup_id, :code => 'dump_error', :message => $!.to_s })
60
- abort_with("dump error: #{$!}")
58
+ abort_with("dump error: #{$!}", :dump_error)
61
59
  ensure
62
60
  [stdin, stdout, stderr].each{|io| io.close unless io.closed? }
63
61
  Process.waitpid(pid)
@@ -65,11 +63,13 @@ module Dumper
65
63
 
66
64
  dump_duration = Time.now - start_at
67
65
  log "dump_duration = #{dump_duration}"
68
- abort_with('max filesize exceeded') if File.size(@database.dump_path) > MAX_FILESIZE
66
+ if (filesize = File.size(@database.dump_path)) > MAX_FILESIZE
67
+ abort_with("max filesize exceeded: #{filesize}", :too_large)
68
+ end
69
69
 
70
70
  upload_to_s3(json[:url], json[:fields])
71
71
 
72
- json = @agent.api_request('backup/commit', :params => { :backup_id => backup_id, :dump_duration => dump_duration.to_i })
72
+ json = @agent.api_request('backup/commit', :params => { :backup_id => @backup_id, :dump_duration => dump_duration.to_i })
73
73
  rescue
74
74
  log_last_error
75
75
  ensure
@@ -94,9 +94,12 @@ module Dumper
94
94
  log_last_error
95
95
  end
96
96
 
97
- def abort_with(text)
97
+ def abort_with(text, code=nil)
98
98
  log text
99
99
  @database.try(:finalize)
100
+ if code
101
+ @agent.api_request('backup/fail', :params => { :backup_id => @backup_id, :code => code.to_s, :message => text })
102
+ end
100
103
  exit!
101
104
  end
102
105
  end
@@ -1,3 +1,3 @@
1
1
  module Dumper
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dumper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: