murakumo 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/misc/murakumo_const.rb +1 -1
- data/lib/srv/murakumo_health_checker_context.rb +43 -24
- metadata +3 -3
data/lib/misc/murakumo_const.rb
CHANGED
@@ -39,34 +39,53 @@ module Murakumo
|
|
39
39
|
|
40
40
|
begin
|
41
41
|
require 'mysql'
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
|
43
|
+
def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
|
44
|
+
port = nil
|
45
|
+
sock = nil
|
46
|
+
|
47
|
+
if port_sock.kind_of?(Integer)
|
48
|
+
port = port_sock
|
49
|
+
else
|
50
|
+
sock = port_sock
|
51
|
+
end
|
52
|
+
|
53
|
+
my = Mysql.new(host, user, passwd, db, port, sock)
|
54
|
+
!!(my.respond_to?(:ping) ? my.ping : my.stat)
|
55
|
+
rescue => e
|
56
|
+
@logger.debug(e.message)
|
57
|
+
return false
|
58
|
+
ensure
|
59
|
+
my.close if my
|
48
60
|
end
|
61
|
+
rescue LoadError
|
49
62
|
end
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
rescue => e
|
66
|
-
@logger.debug(e.message)
|
67
|
-
false
|
64
|
+
begin
|
65
|
+
require 'mysql2'
|
66
|
+
|
67
|
+
def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
|
68
|
+
opts = {}
|
69
|
+
opts[:username] = user
|
70
|
+
opts[:password] = passwd if passwd
|
71
|
+
opts[:host] = host if host
|
72
|
+
opts[:database] = db if db
|
73
|
+
|
74
|
+
if port_sock.kind_of?(Integer)
|
75
|
+
opts[:port] = port_sock
|
76
|
+
else
|
77
|
+
opts[:socket] = port_sock
|
68
78
|
end
|
69
|
-
|
79
|
+
|
80
|
+
my = Mysql2::Client.new(opts)
|
81
|
+
my.ping
|
82
|
+
rescue => e
|
83
|
+
@logger.debug(e.message)
|
84
|
+
return false
|
85
|
+
ensure
|
86
|
+
my.close if my
|
87
|
+
end
|
88
|
+
rescue LoadError
|
70
89
|
end
|
71
90
|
|
72
91
|
end # HealthCheckerContext
|
metadata
CHANGED