mamiya 0.0.1.alpha6 → 0.0.1.alpha7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mamiya/cli/client.rb +17 -2
- data/lib/mamiya/master/web.rb +13 -0
- data/lib/mamiya/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c740e295861a9dc89bd72f70e1f693136306783a
|
4
|
+
data.tar.gz: 4ee69a07bdb07d69a945e150c6a45775c9cc451e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71de35f8913cf2e1dc0af2ed38210cfe0524c8c4c5af7ae3bd7ec1ff974ea57d5aedfccaa86d8307aa9ec157b09e904b1566463c59db41eeae01ff4ad84d604d
|
7
|
+
data.tar.gz: fee51b6ef754f2770ff03edf07a37f4c0a015015d167143c1d0be27f3e24df03a049246427e1d65740f022be371d084476c4bf5f4a12ee024255eaba52cceef1
|
data/lib/mamiya/cli/client.rb
CHANGED
@@ -2,6 +2,7 @@ require 'mamiya/cli'
|
|
2
2
|
|
3
3
|
require 'net/http'
|
4
4
|
require 'net/https'
|
5
|
+
require 'rack/utils'
|
5
6
|
require 'uri'
|
6
7
|
require 'json'
|
7
8
|
require 'thor'
|
@@ -128,6 +129,11 @@ number of agents don't have package: #{dist['not_distributed_count']}
|
|
128
129
|
def rollback
|
129
130
|
end
|
130
131
|
|
132
|
+
desc "join HOST", "let serf to join to HOST"
|
133
|
+
def join(host)
|
134
|
+
master_post('/join', host: host)
|
135
|
+
end
|
136
|
+
|
131
137
|
private
|
132
138
|
|
133
139
|
def fatal!(msg)
|
@@ -146,10 +152,19 @@ number of agents don't have package: #{dist['not_distributed_count']}
|
|
146
152
|
end
|
147
153
|
|
148
154
|
def master_post(path, data='')
|
155
|
+
response = nil
|
149
156
|
master_http.start do |http|
|
150
|
-
|
151
|
-
|
157
|
+
if Hash === data
|
158
|
+
data = Rack::Utils.build_nested_query(data)
|
159
|
+
end
|
160
|
+
|
161
|
+
response = http.post(path, data)
|
162
|
+
response.value
|
163
|
+
response.code == '204' ? true : JSON.parse(response.body)
|
152
164
|
end
|
165
|
+
rescue Net::HTTPExceptions => e
|
166
|
+
puts response.body rescue nil
|
167
|
+
raise e
|
153
168
|
end
|
154
169
|
|
155
170
|
def master_http
|
data/lib/mamiya/master/web.rb
CHANGED
@@ -143,6 +143,19 @@ module Mamiya
|
|
143
143
|
agent_monitor.refresh
|
144
144
|
status 204
|
145
145
|
end
|
146
|
+
|
147
|
+
post '/join' do
|
148
|
+
begin
|
149
|
+
master.serf.join(params[:host])
|
150
|
+
status 204
|
151
|
+
rescue Villein::Client::SerfError => e
|
152
|
+
raise e unless /Error joining the cluster/ === e.message
|
153
|
+
|
154
|
+
content_type :json
|
155
|
+
status 400
|
156
|
+
{error: e.message}.to_json
|
157
|
+
end
|
158
|
+
end
|
146
159
|
end
|
147
160
|
end
|
148
161
|
end
|
data/lib/mamiya/version.rb
CHANGED