murakumo 0.6.0 → 0.6.1
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/README +0 -1
- data/lib/misc/murakumo_const.rb +1 -1
- data/lib/srv/murakumo_health_check_context.rb +21 -20
- metadata +1 -1
data/README
CHANGED
data/lib/misc/murakumo_const.rb
CHANGED
@@ -60,23 +60,26 @@ module Murakumo
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
# MySQLチェッカー
|
63
64
|
begin
|
64
|
-
require '
|
65
|
+
require 'mysql2/em'
|
65
66
|
|
66
67
|
def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
|
67
|
-
|
68
|
-
|
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
|
+
opts[:connect_timeout] = @options['timeout']
|
69
74
|
|
70
75
|
if port_sock.kind_of?(Integer)
|
71
|
-
port = port_sock
|
76
|
+
opts[:port] = port_sock
|
72
77
|
else
|
73
|
-
|
78
|
+
opts[:socket] = port_sock
|
74
79
|
end
|
75
80
|
|
76
|
-
my =
|
77
|
-
my.
|
78
|
-
my.connect(host, user, passwd, db, port, sock)
|
79
|
-
!!(my.respond_to?(:ping) ? my.ping : my.stat)
|
81
|
+
my = Mysql2::EM::Client.new(opts)
|
82
|
+
my.ping
|
80
83
|
rescue => e
|
81
84
|
@logger.debug("#{@name}: #{e.message}")
|
82
85
|
return false
|
@@ -90,24 +93,22 @@ module Murakumo
|
|
90
93
|
|
91
94
|
unless method_defined?(:mysql_check)
|
92
95
|
begin
|
93
|
-
require '
|
96
|
+
require 'mysql'
|
94
97
|
|
95
98
|
def mysql_check(user, passwd = nil, port_sock = 3306, host = '127.0.0.1', db = nil)
|
96
|
-
|
97
|
-
|
98
|
-
opts[:password] = passwd if passwd
|
99
|
-
opts[:host] = host if host
|
100
|
-
opts[:database] = db if db
|
101
|
-
opts[:connect_timeout] = @options['timeout']
|
99
|
+
port = nil
|
100
|
+
sock = nil
|
102
101
|
|
103
102
|
if port_sock.kind_of?(Integer)
|
104
|
-
|
103
|
+
port = port_sock
|
105
104
|
else
|
106
|
-
|
105
|
+
sock = port_sock
|
107
106
|
end
|
108
107
|
|
109
|
-
my =
|
110
|
-
my.
|
108
|
+
my = Mysql.init
|
109
|
+
my.options(Mysql::OPT_CONNECT_TIMEOUT, @options['timeout'])
|
110
|
+
my.connect(host, user, passwd, db, port, sock)
|
111
|
+
!!(my.respond_to?(:ping) ? my.ping : my.stat)
|
111
112
|
rescue => e
|
112
113
|
@logger.debug("#{@name}: #{e.message}")
|
113
114
|
return false
|