-
-
Save samleb/150329 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'active_record' | |
require 'active_support' | |
require 'parseconfig' | |
config = ParseConfig.new( '/path/to/conf/file.conf' ) | |
db_number = Integer(config.get_value( 'database_count' )) | |
database_parameters = (1...db_number).collect do |i| | |
db = config.get_value("DB#{i}") | |
db[1..-2].split(',') | |
end | |
counts = database_parameters.collect do |params| | |
ActiveRecord::Base.establish_connection( | |
:adapter => params[0], | |
:host => params[1], | |
:port => Integer(params[2]), | |
:database => params[3], | |
:username => params[4], | |
:password => params[5] | |
) | |
class Order < ActiveRecord::Base | |
set_table_name "Orders" | |
end | |
Order.count('ID') | |
end | |
if counts.all? { |c| c == counts.first } | |
puts "OK" | |
else | |
db_parameters.each do |params| | |
puts "démerde toi avec ton message d'output :)" | |
end | |
exit 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment