mysql-pause 0.1.6 → 0.1.7
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/mysql-pause/constants.rb +1 -1
- data/lib/mysql-pause/proxy.rb +17 -4
- metadata +1 -1
@@ -1,2 +1,2 @@
|
|
1
1
|
APP_NAME = 'mysql-pause'
|
2
|
-
Version = '0.1.
|
2
|
+
Version = '0.1.7'
|
data/lib/mysql-pause/proxy.rb
CHANGED
@@ -5,6 +5,9 @@ require 'logger'
|
|
5
5
|
require 'socket'
|
6
6
|
|
7
7
|
module MysqlPause
|
8
|
+
RETRY_LIMIT = 100
|
9
|
+
RETRY_INTERVAL = 3
|
10
|
+
|
8
11
|
class Proxy < EM::Connection
|
9
12
|
attr_reader :options
|
10
13
|
attr_reader :logger
|
@@ -13,15 +16,25 @@ module MysqlPause
|
|
13
16
|
@options = options
|
14
17
|
@logger = Logger.new($stdout)
|
15
18
|
|
19
|
+
n = 0
|
20
|
+
|
16
21
|
begin
|
17
22
|
ping(be_host, be_port)
|
18
23
|
@backend = EM.connect(be_host, be_port, MysqlPause::Backend, self)
|
19
|
-
raise('
|
24
|
+
raise('connection error') if @backend.error?
|
20
25
|
rescue => e
|
21
26
|
@logger.error("#{e.class.name}: #{e.message}")
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
|
28
|
+
if n < RETRY_LIMIT
|
29
|
+
close_backend_connection
|
30
|
+
sleep RETRY_INTERVAL
|
31
|
+
@logger.warn("connection retry")
|
32
|
+
n += 1
|
33
|
+
retry
|
34
|
+
else
|
35
|
+
@logger.error("connection abort")
|
36
|
+
raise e
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
27
40
|
|