murakumo 0.4.6 → 0.4.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/misc/murakumo_const.rb +1 -1
- data/lib/srv/murakumo_cloud.rb +49 -44
- metadata +3 -3
data/lib/misc/murakumo_const.rb
CHANGED
data/lib/srv/murakumo_cloud.rb
CHANGED
@@ -35,7 +35,7 @@ module Murakumo
|
|
35
35
|
@logger = options[:logger]
|
36
36
|
|
37
37
|
# 名前は小文字に変換
|
38
|
-
datas = ([host_data] + alias_datas).map do |i|
|
38
|
+
@initial_datas = datas = ([host_data] + alias_datas).map do |i|
|
39
39
|
name, ttl, priority, weight, activity = i
|
40
40
|
name = name.downcase
|
41
41
|
[name, ttl, priority, weight, activity]
|
@@ -48,34 +48,6 @@ module Murakumo
|
|
48
48
|
# updateの後にホスト名をセットすること
|
49
49
|
@hostname = host_data.first
|
50
50
|
|
51
|
-
# ゴシップオブジェクトを生成
|
52
|
-
@gossip = RGossip2.client({
|
53
|
-
:initial_nodes => options[:initial_nodes],
|
54
|
-
:address => @address,
|
55
|
-
:data => datas,
|
56
|
-
:auth_key => options[:auth_key],
|
57
|
-
:port => options[:gossip_port],
|
58
|
-
:node_lifetime => options[:gossip_node_lifetime],
|
59
|
-
:gossip_interval => options[:gossip_send_interval],
|
60
|
-
:receive_timeout => options[:gossip_receive_timeout],
|
61
|
-
:logger => @logger,
|
62
|
-
:ping_init_nodes => options[:ping_init_nodes],
|
63
|
-
})
|
64
|
-
|
65
|
-
# ノードの更新をフック
|
66
|
-
@gossip.context.callback_handler = lambda do |act, addr, ts, dt, old_dt|
|
67
|
-
case act
|
68
|
-
when :add, :comeback
|
69
|
-
# 追加・復帰の時は無条件に更新
|
70
|
-
update(addr, dt)
|
71
|
-
when :update
|
72
|
-
# 更新の時はデータが更新されたときのみ更新
|
73
|
-
update(addr, dt) if dt != old_dt
|
74
|
-
when :delete
|
75
|
-
delete(addr)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
51
|
# ヘルスチェック
|
80
52
|
@health_checkers = {}
|
81
53
|
|
@@ -142,30 +114,63 @@ module Murakumo
|
|
142
114
|
# Control of service
|
143
115
|
def_delegators :@gossip, :stop, :clear_dead_list
|
144
116
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
117
|
+
# ゴシップオブジェクトを生成
|
118
|
+
def create_gossip
|
119
|
+
@gossip = RGossip2.client({
|
120
|
+
:initial_nodes => @options[:initial_nodes],
|
121
|
+
:address => @address,
|
122
|
+
:data => @initial_datas,
|
123
|
+
:auth_key => @options[:auth_key],
|
124
|
+
:port => @options[:gossip_port],
|
125
|
+
:node_lifetime => @options[:gossip_node_lifetime],
|
126
|
+
:gossip_interval => @options[:gossip_send_interval],
|
127
|
+
:receive_timeout => @options[:gossip_receive_timeout],
|
128
|
+
:logger => @logger,
|
129
|
+
:ping_init_nodes => @options[:ping_init_nodes],
|
130
|
+
})
|
156
131
|
|
157
|
-
#
|
158
|
-
|
159
|
-
|
132
|
+
# ノードの更新をフック
|
133
|
+
@gossip.context.callback_handler = lambda do |act, addr, ts, dt, old_dt|
|
134
|
+
case act
|
135
|
+
when :add, :comeback
|
136
|
+
# 追加・復帰の時は無条件に更新
|
137
|
+
update(addr, dt)
|
138
|
+
when :update
|
139
|
+
# 更新の時はデータが更新されたときのみ更新
|
140
|
+
update(addr, dt) if dt != old_dt
|
141
|
+
when :delete
|
142
|
+
delete(addr)
|
143
|
+
end
|
160
144
|
end
|
145
|
+
end
|
161
146
|
|
147
|
+
def start
|
162
148
|
@logger.info("Delay of a gossip start: #{@options[:gossip_start_delay]}")
|
163
149
|
|
164
150
|
Thread.start do
|
165
151
|
# ゴシッププロトコルの開始を遅延
|
166
152
|
sleep @options[:gossip_start_delay]
|
167
153
|
|
168
|
-
@logger.info('Gossip
|
154
|
+
@logger.info('Gossip is starting')
|
155
|
+
# ゴシップオブジェクトを生成
|
156
|
+
create_gossip
|
157
|
+
|
158
|
+
# デーモン化すると子プロセスはすぐ死ぬので
|
159
|
+
# このタイミングでヘルスチェックを起動
|
160
|
+
@health_checkers.each do |name, checker|
|
161
|
+
checker.start
|
162
|
+
end
|
163
|
+
|
164
|
+
# アクティビティチェックを起動
|
165
|
+
@activity_checkers.each do |name, checker|
|
166
|
+
checker.start
|
167
|
+
end
|
168
|
+
|
169
|
+
# 起動時フックスクリプトの実行
|
170
|
+
if @options[:on_start]
|
171
|
+
exec_start_script(@options[:on_start])
|
172
|
+
end
|
173
|
+
|
169
174
|
@gossip.start
|
170
175
|
end
|
171
176
|
end
|
metadata
CHANGED