Created
September 28, 2016 10:20
-
-
Save crigor/9d2d747e8929c5dbd8a7fc455a506256 to your computer and use it in GitHub Desktop.
Modified version of tpol's script. Uses mysql2 gem.
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 | |
# gem install mysql2 -v 0.3.12b6 | |
#require 'mysql' | |
require 'mysql2' | |
def usage | |
puts "USAGE: connect.rb <connections> [<runtime>]" | |
exit | |
end | |
usage unless ARGV.length >= 1 | |
connections, runtime = ARGV | |
runtime = runtime.nil? ? 100 : runtime.to_i | |
conn_arry = [] | |
(1..connections.to_i).each do |n| | |
begin | |
#conn_arry[n] = Mysql.real_connect( '127.0.0.1','deploy', 'PASSWORD', 'DBNAME') | |
conn_arry[n] = Mysql2::Client.new( :host => '127.0.0.1', :username => 'deploy', :password => 'PASSWORD', :database => 'DBNAME') | |
puts "Progress: #{n} connections" if n % 2000 == 0 | |
rescue Exception => e | |
puts e.message | |
puts "At #{n} connections" | |
break | |
end | |
end | |
puts "Reached #{conn_arry.length}." | |
sleep (runtime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment