dev-consul 0.6.4.2 → 0.6.4.3
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.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/dev/consul.rb +36 -24
- data/lib/dev/consul/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2029c024629f6905adb767d67b2bc3bb593763ff
|
|
4
|
+
data.tar.gz: 1a3e128053da30c1e21c52907c5ea350383eb2e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9068614d369eba883ae5648b5cb332d7b150ffb519b78ee08721e523d5956640621a0b3263aa808a55c18ea596da69be54258af3286857a96ae06cff3ccd45f5
|
|
7
|
+
data.tar.gz: 3eba8bc39d4d00044b5dee1ea8a37594b04b499dcf740be1025603385310714b7c36eec0a8e765626be6e1800403d9d6b216e53366bea28e1b49d473086760c5
|
data/Rakefile
CHANGED
data/lib/dev/consul.rb
CHANGED
|
@@ -36,72 +36,84 @@ module Dev
|
|
|
36
36
|
File.join(bindir, "consul_#{VERSION}_#{platform}_#{architecture}")
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
attr_reader :output
|
|
40
|
+
|
|
41
|
+
## Logging helper
|
|
42
|
+
def log(*message)
|
|
43
|
+
return unless output.is_a?(IO)
|
|
44
|
+
|
|
45
|
+
output.write(message.join(' ') + "\n")
|
|
46
|
+
output.flush
|
|
42
47
|
end
|
|
43
48
|
|
|
44
|
-
def run
|
|
45
|
-
|
|
49
|
+
def run(**options)
|
|
50
|
+
@output = options.fetch(:output, $stdout)
|
|
51
|
+
log "Starting #{bin}"
|
|
52
|
+
|
|
46
53
|
|
|
47
54
|
## Fork a child process for Consul from a thread
|
|
55
|
+
@stopped = false
|
|
48
56
|
@thread = Thread.new do
|
|
49
57
|
IO.popen("#{bin} agent -dev -advertise=127.0.0.1", 'r+') do |io|
|
|
50
58
|
Thread.current[:process] = io.pid
|
|
51
|
-
|
|
59
|
+
log "Started #{bin} (#{io.pid})"
|
|
52
60
|
|
|
53
61
|
## Stream output
|
|
54
62
|
loop do
|
|
55
63
|
break if io.eof?
|
|
56
64
|
chunk = io.readpartial(1024)
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
end
|
|
66
|
+
next unless output.is_a?(IO)
|
|
67
|
+
output.write(chunk)
|
|
68
|
+
output.flush
|
|
62
69
|
end
|
|
63
70
|
end
|
|
64
71
|
end
|
|
65
72
|
|
|
66
|
-
|
|
73
|
+
self
|
|
74
|
+
end
|
|
67
75
|
|
|
76
|
+
def wait
|
|
68
77
|
## Wait for the service to become ready
|
|
69
78
|
loop do
|
|
70
|
-
|
|
71
|
-
leader = Net::HTTP.get('localhost', '/v1/status/leader', 8500)
|
|
79
|
+
break if @stopped || @thread.nil? || !@thread.alive?
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
leader =
|
|
82
|
+
begin
|
|
83
|
+
Net::HTTP.get('localhost', '/v1/status/leader', 8500)
|
|
84
|
+
rescue Errno::ECONNREFUSED
|
|
85
|
+
log 'Waiting for Consul HTTP API to be ready'
|
|
75
86
|
sleep 1
|
|
76
|
-
|
|
77
87
|
next
|
|
78
88
|
end
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
rescue Errno::ECONNREFUSED
|
|
84
|
-
puts 'Waiting for Consul HTTP API to be ready'
|
|
90
|
+
if leader == '""'
|
|
91
|
+
log 'Waiting for RAFT to initialize'
|
|
85
92
|
sleep 1
|
|
93
|
+
next
|
|
86
94
|
end
|
|
95
|
+
|
|
96
|
+
log 'Consul HTTP API is ready!'
|
|
97
|
+
break
|
|
87
98
|
end
|
|
88
99
|
end
|
|
89
100
|
|
|
90
|
-
def
|
|
101
|
+
def block
|
|
91
102
|
@thread.join unless @thread.nil?
|
|
92
103
|
end
|
|
93
104
|
|
|
94
105
|
def stop
|
|
95
106
|
unless @thread.nil?
|
|
96
107
|
unless @thread[:process].nil?
|
|
97
|
-
|
|
98
|
-
Process.kill('
|
|
108
|
+
log "Stop #{bin} (#{@thread[:process]})"
|
|
109
|
+
Process.kill('TERM', @thread[:process])
|
|
99
110
|
end
|
|
100
111
|
|
|
101
112
|
@thread.join
|
|
102
113
|
end
|
|
103
114
|
|
|
104
115
|
@thread = nil
|
|
116
|
+
@stopped = true
|
|
105
117
|
end
|
|
106
118
|
end
|
|
107
119
|
end
|
data/lib/dev/consul/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dev-consul
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.4.
|
|
4
|
+
version: 0.6.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Manero
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-05-
|
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: zipruby
|