dumper 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dumper/job.rb +10 -7
- data/lib/dumper/version.rb +1 -1
- metadata +1 -1
data/lib/dumper/job.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/dumper/version.rb
CHANGED