bin/lhm-kill-queue in lhm-2.1.0 vs bin/lhm-kill-queue in lhm-2.2.0

- old
+ new

@@ -4,32 +4,31 @@ require 'lhm/sql_helper' require 'optparse' module Lhm class KillQueue - def initialize @port = 3306 @grace = 10 @tiny = 0.1 @marker = "%#{ SqlHelper.annotation }%" OptionParser.new do |opts| - opts.on("-h", "--hostname HOSTNAME") { |v| @hostname = v } - opts.on("-u", "--username USERNAME") { |v| @username = v } - opts.on("-p", "--password PASSWORD") { |v| @password = v } - opts.on("-d", "--database DATABASE") { |v| @database = v } - opts.on("-m", "--mode MODE") { |v| @mode = v.to_sym } - opts.on("-y", "--confirm") { |v| @confirm = true } + opts.on('-h', '--hostname HOSTNAME') { |v| @hostname = v } + opts.on('-u', '--username USERNAME') { |v| @username = v } + opts.on('-p', '--password PASSWORD') { |v| @password = v } + opts.on('-d', '--database DATABASE') { |v| @database = v } + opts.on('-m', '--mode MODE') { |v| @mode = v.to_sym } + opts.on('-y', '--confirm') { |v| @confirm = true } end.parse! - unless(@hostname && @username && @password && @database) + unless (@hostname && @username && @password && @database) abort usage end - unless([:kill, :master, :slave].include?(@mode)) - abort "specify -m kill OR -m master OR -m slave" + unless ([:kill, :master, :slave].include?(@mode)) + abort 'specify -m kill OR -m master OR -m slave' end connect end @@ -71,11 +70,11 @@ lock = trip puts "starting to kill non lhm SELECT processes in #{ @grace } seconds" sleep(@grace + @tiny) [list_non_lhm].flatten.each do |process| - if(select?(process)) + if (select?(process)) kill_process(process) sleep(@tiny) end end end @@ -113,15 +112,15 @@ end def kill_process(process_id) puts "killing #{ select_statement(process_id) }" - if(@confirm) + if (@confirm) print "confirm ('y' to confirm): " - if(gets.strip != 'y') - puts "skipped." + if (gets.strip != 'y') + puts 'skipped.' return end end connection.execute("kill #{ process_id }") @@ -167,6 +166,5 @@ end end killer = Lhm::KillQueue.new killer.run -