dumper 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dumper/agent.rb +4 -2
- data/lib/dumper/database/mysql.rb +1 -1
- data/lib/dumper/stack.rb +19 -1
- data/lib/dumper/version.rb +1 -1
- metadata +2 -2
data/lib/dumper/agent.rb
CHANGED
@@ -45,10 +45,12 @@ module Dumper
|
|
45
45
|
log "sleeping #{sec} seconds for agent/register.", :debug
|
46
46
|
sleep sec
|
47
47
|
json = send_request(api: 'agent/register', json: MultiJson.encode(register_hash))
|
48
|
-
end until json[:status]
|
48
|
+
end until json[:status]
|
49
|
+
|
50
|
+
return log("agent stopped: #{json.to_s}") if json[:status] == 'error'
|
49
51
|
|
50
|
-
log 'agent started.'
|
51
52
|
@token = json[:token]
|
53
|
+
log "agent started as #{@token ? 'primary' : 'secondary'}"
|
52
54
|
sleep 1.hour unless @token
|
53
55
|
|
54
56
|
loop do
|
@@ -2,7 +2,7 @@ module Dumper
|
|
2
2
|
module Database
|
3
3
|
class MySQL < Base
|
4
4
|
def command
|
5
|
-
"mysqldump #{connection_options} #{additional_options} #{@stack.activerecord_config['database']} | gzip"
|
5
|
+
"#{@stack.dump_tool(:mysqldump)} #{connection_options} #{additional_options} #{@stack.activerecord_config['database']} | gzip"
|
6
6
|
end
|
7
7
|
|
8
8
|
protected
|
data/lib/dumper/stack.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Dumper
|
2
2
|
class Stack
|
3
|
+
DUMP_TOOLS = {}
|
4
|
+
|
3
5
|
attr_accessor :rails_env, :dispatcher, :framework, :rackup, :activerecord_config
|
4
6
|
|
5
7
|
def initialize
|
@@ -30,12 +32,28 @@ module Dumper
|
|
30
32
|
rails_version: @rails_version,
|
31
33
|
dispatcher: @dispatcher,
|
32
34
|
activerecord_config: @activerecord_config.reject{|k,v| k == 'password' },
|
35
|
+
dump_tools: DUMP_TOOLS,
|
33
36
|
}
|
34
37
|
end
|
35
38
|
|
36
39
|
# Compatibility
|
37
40
|
def supported?
|
38
|
-
@is_supported_rails_version && @dispatcher &&
|
41
|
+
@is_supported_rails_version && @dispatcher && mysql?
|
42
|
+
end
|
43
|
+
|
44
|
+
# Database
|
45
|
+
def mysql?
|
46
|
+
dump_tool(:mysqldump) # Just assign DUMP_TOOLS
|
47
|
+
%w(mysql mysql2).include?(@activerecord_config['adapter'])
|
48
|
+
end
|
49
|
+
|
50
|
+
# Dump Tool
|
51
|
+
def dump_tool(name)
|
52
|
+
DUMP_TOOLS[name] ||= `which #{name}`.chomp
|
53
|
+
end
|
54
|
+
|
55
|
+
def dump_tool_installed?(name)
|
56
|
+
!dump_tool(name).empty?
|
39
57
|
end
|
40
58
|
|
41
59
|
# Dispatcher
|
data/lib/dumper/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|