-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Dumper | ||
module Config | ||
class MySQL < Base | ||
def initialize(additional_env: nil) | ||
@rails_env = additional_env || Rails.env | ||
|
||
return unless exist? | ||
|
||
@host = @config['host'] | ||
@port = @config['port'] | ||
@database = @config['database'] | ||
@username = @config['username'] | ||
@password = @config['password'] | ||
end | ||
|
||
def exist? | ||
defined?(ActiveRecord::Base) and | ||
ActiveRecord::Base.configurations and | ||
@config = ActiveRecord::Base.configurations[@rails_env] and | ||
%w(mysql mysql2 mysql2spatial).include?(@config['adapter']) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Dumper | ||
module Config | ||
class PostgreSQL < Base | ||
def initialize(additional_env: nil) | ||
@rails_env = additional_env || Rails.env | ||
|
||
return unless exist? | ||
|
||
@host = @config['host'] | ||
@port = @config['port'] | ||
@database = @config['database'] | ||
@username = @config['username'] | ||
@password = @config['password'] | ||
end | ||
|
||
def exist? | ||
defined?(ActiveRecord::Base) and | ||
ActiveRecord::Base.configurations and | ||
@config = ActiveRecord::Base.configurations[@rails_env] and | ||
@config['adapter'] == 'postgresql' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Dumper | ||
module Config | ||
class Redis < Base | ||
def initialize(additional_env: nil) | ||
return unless exist? | ||
|
||
@host = @client.host | ||
@port = @client.port | ||
@database = @client.db | ||
@password = @client.password | ||
@dbpath = dbpath | ||
end | ||
|
||
def exist? | ||
return unless main_thread_redis = first_instance_of('::Redis') | ||
|
||
# redis-rb v4 added CLIENT command support | ||
m = main_thread_redis.respond_to?(:_client) ? :_client : :client | ||
@client = main_thread_redis.send(m) | ||
|
||
# New connection for the agent thread | ||
redis = ::Redis.new(host: @client.host, port: @client.port, password: @client.password, db: @client.db) | ||
dir = redis.config(:get, :dir)['dir'] | ||
dbfilename = redis.config(:get, :dbfilename)['dbfilename'] | ||
dbpath = "#{dir}/#{dbfilename}" | ||
|
||
return unless File.exist?(dbpath) # Redis must run on the back up node | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters