mtncd 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +2 -2
- data/bin/mtncd +93 -101
- data/lib/mtncd/version.rb +1 -1
- data/mtncd.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmE3Zjk5ZTM2N2NlMmYzODg2NjQzMDJlYmQ0YzQyNzNiNjhkZTQ4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzA1Y2I5Yzc2M2YxN2QzODM5NzBiMTFhMGRkYThhM2JlZDJjODgyNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Nzc0Njg0ZWNkNGQ5ZDNmZjkxZjE3OTQyYTA5NDI1ODhmMWNkODg0YzI5ZDA0
|
10
|
+
N2ZmM2JhM2ZjYjI0YjE4ODYxNjNmMWY3MjA1ODg1ZmZiYjM0ODMwNGY1ZmJi
|
11
|
+
NjE3NDY1N2MyNGMxYTA3N2ZiNDg0MTdhNjI3ZTRlYjI1ZGNmYjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2I3YjFhNWVhNDUzYjcwYTIxYWYzNmY4NzZkZGI4YWZjMjljYTI1MmFjNThl
|
14
|
+
MGVlZDg3ZTMyNDUyYzFjYWI2MTI2NDg3ZTIzYjM0ZGVjMzYyZDU5YjNkYzZl
|
15
|
+
NDU5Yzg5OTU3YjVjZjVlYzM3YWVhMmMwNjdlNjVkMDI0YjE5NWE=
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mtncd (0.0.
|
4
|
+
mtncd (0.0.8)
|
5
5
|
awesome_print (= 1.2.0)
|
6
6
|
gli (= 2.12.2)
|
7
7
|
msgpack (= 0.5.9)
|
@@ -37,7 +37,7 @@ GEM
|
|
37
37
|
msgpack (0.5.9)
|
38
38
|
multi_json (1.10.1)
|
39
39
|
multi_test (0.1.1)
|
40
|
-
rack (1.
|
40
|
+
rack (1.6.0)
|
41
41
|
rack-protection (1.5.3)
|
42
42
|
rack
|
43
43
|
rake (10.3.2)
|
data/bin/mtncd
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# encoding
|
3
3
|
require 'gli'
|
4
4
|
require 'mtncd'
|
5
|
-
require '
|
5
|
+
require 'json'
|
6
6
|
require 'securerandom'
|
7
7
|
require 'serfx'
|
8
8
|
require 'resque'
|
@@ -10,6 +10,8 @@ require 'msgpack'
|
|
10
10
|
require 'awesome_print'
|
11
11
|
require 'redis'
|
12
12
|
require 'open3'
|
13
|
+
require 'resque'
|
14
|
+
require 'highline/import'
|
13
15
|
|
14
16
|
include GLI::App
|
15
17
|
|
@@ -35,7 +37,7 @@ command :deploy do |deploy|
|
|
35
37
|
}
|
36
38
|
|
37
39
|
start.desc 'use deployment id'
|
38
|
-
start.default_value SecureRandom.
|
40
|
+
start.default_value SecureRandom.hex(4)
|
39
41
|
start.flag :id
|
40
42
|
|
41
43
|
start.desc 'local or global cluster command'
|
@@ -56,17 +58,6 @@ command :deploy do |deploy|
|
|
56
58
|
start.switch :single
|
57
59
|
|
58
60
|
start.action do |global_options,options,args|
|
59
|
-
if $config['role'] == 'sled' && options[:cluster] == 'global'
|
60
|
-
raise 'global commands are only available on central or infra nodes'
|
61
|
-
end
|
62
|
-
|
63
|
-
if $config['role'] == 'central' && options[:cluster] == 'local'
|
64
|
-
raise 'local commands are only available on infra or sled nodes'
|
65
|
-
end
|
66
|
-
|
67
|
-
if $config['role'] == 'zi' && options[:cluster] == 'local'
|
68
|
-
raise "local status is only available on infra or sled nodes"
|
69
|
-
end
|
70
61
|
|
71
62
|
event_options_hash = {
|
72
63
|
'id' => "#{options[:id]}",
|
@@ -77,10 +68,10 @@ command :deploy do |deploy|
|
|
77
68
|
event_options_hash['shipcodes'] = options[:ships].split(",") unless options[:ships].nil?
|
78
69
|
|
79
70
|
serf_options_hash = {
|
80
|
-
'ip' => $config['
|
81
|
-
'port' => $config['
|
82
|
-
'auth' => $config['
|
83
|
-
'event' =>
|
71
|
+
'ip' => $config['serf'][options[:cluster]]['rpc_ip'],
|
72
|
+
'port' => $config['serf'][options[:cluster]]['rpc_port'],
|
73
|
+
'auth' => $config['serf'][options[:cluster]]['rpc_auth'],
|
74
|
+
'event' => 'deploy'
|
84
75
|
}
|
85
76
|
|
86
77
|
begin
|
@@ -107,27 +98,16 @@ command :deploy do |deploy|
|
|
107
98
|
}
|
108
99
|
|
109
100
|
stop.action do |global_options,options,args|
|
110
|
-
if $config['role'] == 'sled' && options[:cluster] == 'global'
|
111
|
-
raise 'global commands are only available on central or infra nodes'
|
112
|
-
end
|
113
|
-
|
114
|
-
if $config['role'] == 'central' && options[:cluster] == 'local'
|
115
|
-
raise 'local commands are only available on infra or sled nodes'
|
116
|
-
end
|
117
|
-
|
118
|
-
if $config['role'] == 'zi' && options[:cluster] == 'local'
|
119
|
-
raise "local status is only available on infra or sled nodes"
|
120
|
-
end
|
121
101
|
|
122
102
|
event_options_hash = {
|
123
103
|
'id' => "#{options[:id]}"
|
124
104
|
}
|
125
105
|
|
126
106
|
serf_options_hash = {
|
127
|
-
'ip' => $config['
|
128
|
-
'port' => $config['
|
129
|
-
'auth' => $config['
|
130
|
-
'event' =>
|
107
|
+
'ip' => $config['serf'][options[:cluster]]['rpc_ip'],
|
108
|
+
'port' => $config['serf'][options[:cluster]]['rpc_port'],
|
109
|
+
'auth' => $config['serf'][options[:cluster]]['rpc_auth'],
|
110
|
+
'event' => 'stop_deploy'
|
131
111
|
}
|
132
112
|
|
133
113
|
begin
|
@@ -161,22 +141,10 @@ command :status do |status|
|
|
161
141
|
|
162
142
|
status.action do |global_options,options,args|
|
163
143
|
|
164
|
-
if $config['role'] == 'sled' && options[:cluster] == 'global'
|
165
|
-
raise "global status is only available on central or infra nodes"
|
166
|
-
end
|
167
|
-
|
168
|
-
if $config['role'] == 'central' && options[:cluster] == 'local'
|
169
|
-
raise "local status is only available on infra or sled nodes"
|
170
|
-
end
|
171
|
-
|
172
|
-
if $config['role'] == 'zi' && options[:cluster] == 'local'
|
173
|
-
raise "local status is only available on infra or sled nodes"
|
174
|
-
end
|
175
|
-
|
176
144
|
serf_options_hash = {
|
177
|
-
'ip' => $config['
|
178
|
-
'port' => $config['
|
179
|
-
'auth' => $config['
|
145
|
+
'ip' => $config['serf'][options[:cluster]]['rpc_ip'],
|
146
|
+
'port' => $config['serf'][options[:cluster]]['rpc_port'],
|
147
|
+
'auth' => $config['serf'][options[:cluster]]['rpc_auth']
|
180
148
|
}
|
181
149
|
|
182
150
|
command_string = serf_options_hash['auth'].nil? ? "serf members -rpc-addr=#{serf_options_hash['ip']}:#{serf_options_hash['port']}" : "serf members -rpc-addr=#{serf_options_hash['ip']}:#{serf_options_hash['port']} -rpc-auth=#{serf_options_hash['auth']}"
|
@@ -190,7 +158,6 @@ command :status do |status|
|
|
190
158
|
end
|
191
159
|
end
|
192
160
|
|
193
|
-
|
194
161
|
desc 'Status of pipeline components on this particular machine'
|
195
162
|
command :system do |system|
|
196
163
|
system.action do |global_options,options,args|
|
@@ -198,26 +165,26 @@ command :system do |system|
|
|
198
165
|
# check redis
|
199
166
|
result = "OK"
|
200
167
|
begin
|
201
|
-
redis = Redis.new(:host => $config['
|
168
|
+
redis = Redis.new(:host => $config['resque']['redis_ip'], :port => $config['resque']['redis_port'], :db => $config['resque']['redis_db'])
|
202
169
|
redis.ping
|
203
170
|
rescue
|
204
171
|
result = "\033[31mFAIL\033[0m"
|
205
172
|
success = false
|
206
173
|
end
|
207
|
-
puts "Redis - Connected to #{$config['
|
174
|
+
puts "Redis - Connected to #{$config['resque']['redis_ip']}:#{$config['resque']['redis_port']}/#{$config['resque']['redis_db']} - [#{result}]"
|
208
175
|
|
209
176
|
# check resque
|
210
177
|
begin
|
211
|
-
Resque.redis = "#{$config['
|
178
|
+
Resque.redis = "#{$config['resque']['redis_ip']}:#{$config['resque']['redis_port']}/#{$config['resque']['redis_db']}"
|
212
179
|
|
213
180
|
# clean up any workers that didn't exit gracefuly.
|
214
181
|
Resque.workers.each { |worker|
|
215
182
|
worker.prune_dead_workers
|
216
183
|
}
|
217
184
|
|
218
|
-
result = (Resque.workers.count == $config['
|
219
|
-
success = Resque.workers.count == $config['
|
220
|
-
puts "Resque - Should have #{$config['
|
185
|
+
result = (Resque.workers.count == $config['resque']['worker_count']) ? "OK" : "\033[31mFAIL\033[0m"
|
186
|
+
success = Resque.workers.count == $config['resque']['worker_count'] unless success == false
|
187
|
+
puts "Resque - Should have #{$config['resque']['worker_count']} workers, running #{Resque.workers.count} workers - [#{result}]"
|
221
188
|
rescue
|
222
189
|
result = "\033[31mFAIL\033[0m"
|
223
190
|
success = false
|
@@ -225,9 +192,9 @@ command :system do |system|
|
|
225
192
|
end
|
226
193
|
|
227
194
|
# check serf
|
228
|
-
if $config['role']
|
195
|
+
if $config['role'] == 'ship' || $config['role'] == 'sled'
|
229
196
|
begin
|
230
|
-
Serfx.connect(host: $config['
|
197
|
+
Serfx.connect(host: $config['serf']['local']['rpc_ip'], port: $config['serf']['local']['rpc_port'], authkey: $config['serf']['local']['rpc_auth']) do |conn|
|
231
198
|
result = (conn.members.body['Members'].length > 1) ? "OK" : "\033[31mFAIL\033[0m"
|
232
199
|
end
|
233
200
|
rescue Serfx::RPCError => e
|
@@ -240,7 +207,7 @@ command :system do |system|
|
|
240
207
|
|
241
208
|
if $config['role'] != 'sled'
|
242
209
|
begin
|
243
|
-
Serfx.connect(host: $config['
|
210
|
+
Serfx.connect(host: $config['serf']['global']['rpc_ip'], port: $config['serf']['global']['rpc_port'], authkey:$config['serf']['global']['rpc_auth']) do |conn|
|
244
211
|
result = (conn.members.body['Members'].length > 1) ? "OK" : "\033[31mFAIL\033[0m"
|
245
212
|
end
|
246
213
|
rescue Serfx::RPCError => e
|
@@ -251,54 +218,69 @@ command :system do |system|
|
|
251
218
|
puts "Serf Global Cluster - connected and has more than one member - [#{result}]"
|
252
219
|
end
|
253
220
|
|
254
|
-
|
221
|
+
node_name = ($config['role'] == 'sled') ? $config['serf']['local']['node_name'] : $config['serf']['global']['node_name']
|
222
|
+
|
223
|
+
raise "Pipeline node #{node_name} is likely unstable" unless success == true
|
255
224
|
end
|
256
225
|
end
|
257
226
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
227
|
+
desc 'resque information'
|
228
|
+
command :resque do |resque|
|
229
|
+
resque.desc 'resque information'
|
230
|
+
resque.command :info do |info|
|
231
|
+
info.action do |global_options,options,args|
|
232
|
+
Resque.redis = "#{$config['resque']['redis_ip']}:#{$config['resque']['redis_port']}/#{$config['resque']['redis_db']}"
|
233
|
+
|
234
|
+
# get the queues
|
235
|
+
queues = Resque.queues
|
236
|
+
puts "Resque queues: #{queues.inspect}"
|
237
|
+
queues.each do |queue|
|
238
|
+
puts "Jobs in queue #{queue}: #{Resque.size(queue)}"
|
239
|
+
queued_jobs = Resque.peek(queue)
|
240
|
+
unless queued_jobs.nil?
|
241
|
+
Resque.peek(queue, 0, Resque.size(queue)).each { |job|
|
242
|
+
puts job
|
243
|
+
}
|
244
|
+
end
|
245
|
+
end
|
265
246
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
if $config['role'] == 'central' || $config['role'] == 'ship' || $config['role'] == 'zi'
|
272
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['deploy']['global'].nil?
|
273
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['deploy']['global']['stop'].nil?
|
274
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['deploy']['global']['start'].nil?
|
275
|
-
end
|
247
|
+
puts "All worker info:"
|
248
|
+
Resque::Worker.all.each { |worker|
|
249
|
+
puts "Worker #{worker.to_s} assigned to queue #{worker.queues}"
|
250
|
+
}
|
276
251
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
252
|
+
puts "Currently processing workers:"
|
253
|
+
Resque::Worker.working.each { |worker|
|
254
|
+
puts "Worker #{worker.to_s} processing job #{worker.job}"
|
255
|
+
}
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
resque.desc 'flush redis (destructive)'
|
260
|
+
resque.command :flush do |flush|
|
261
|
+
flush.action do |global_options,options,args|
|
262
|
+
redis = Redis.new(:host => $config['resque']['redis_ip'], :port => $config['resque']['redis_port'], :db => $config['resque']['redis_db'])
|
263
|
+
|
264
|
+
res = ask("Enter 'flush' to continue or anything else to cancel.")
|
265
|
+
if res == 'flush'
|
266
|
+
redis.flushall
|
267
|
+
else
|
268
|
+
puts 'Cancelled'
|
269
|
+
end
|
270
|
+
end
|
281
271
|
end
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['redis']['db'].nil?
|
291
|
-
|
292
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['serf'].nil?
|
293
|
-
if $config['role'] == 'central' || $config['role'] == 'ship' || $config['role'] == 'zi'
|
294
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['serf']['global'].nil?
|
295
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['serf']['global']['ip'].nil?
|
296
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['serf']['global']['port'].nil?
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
pre do |global,command,options,args|
|
276
|
+
$config = JSON.parse(File.read(File.join(Dir.home, '.cicdconfig')))
|
277
|
+
|
278
|
+
if $config['role'] == 'sled' && options[:cluster] == 'global'
|
279
|
+
raise 'global commands are not available on sled nodes'
|
297
280
|
end
|
298
|
-
|
299
|
-
|
300
|
-
raise
|
301
|
-
raise "Invalid #{File.join(Dir.home, '.mtncdconf')}" if $config['system']['serf']['local']['port'].nil?
|
281
|
+
|
282
|
+
if $config['role'] == 'central' && options[:cluster] == 'local'
|
283
|
+
raise 'local commands are not available on central nodes'
|
302
284
|
end
|
303
285
|
|
304
286
|
true
|
@@ -311,9 +293,19 @@ post do |global,command,options,args|
|
|
311
293
|
end
|
312
294
|
|
313
295
|
on_error do |exception|
|
314
|
-
|
315
|
-
|
316
|
-
|
296
|
+
case exception
|
297
|
+
when SystemCallError
|
298
|
+
$stderr.puts "Could not find pipeline configuration file at #{File.join(Dir.home, '.cicdconfig')}"
|
299
|
+
false
|
300
|
+
when JSON::ParserError
|
301
|
+
$stderr.puts "Configuration file at #{File.join(Dir.home, '.cicdconfig')} is not valid JSON"
|
302
|
+
false
|
303
|
+
when NoMethodError
|
304
|
+
$stderr.puts "Configuration file at #{File.join(Dir.home, '.cicdconfig')} is most likely missing required sections"
|
305
|
+
false
|
306
|
+
else
|
307
|
+
true
|
308
|
+
end
|
317
309
|
end
|
318
310
|
|
319
311
|
exit run(ARGV)
|
data/lib/mtncd/version.rb
CHANGED
data/mtncd.gemspec
CHANGED
@@ -21,6 +21,7 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency('msgpack', '0.5.9')
|
22
22
|
s.add_dependency('awesome_print', '1.2.0')
|
23
23
|
s.add_dependency('redis', '3.1.0')
|
24
|
+
s.add_dependency('highline', '1.6.21')
|
24
25
|
s.add_development_dependency('rake')
|
25
26
|
s.add_development_dependency('rdoc')
|
26
27
|
s.add_development_dependency('aruba')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtncd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MTN Satellite Communications
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: resque
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: highline
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.6.21
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.6.21
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|