consul-template-generator 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/consul/template/generator.rb +1 -1
- data/lib/consul/template/generator/cmd.rb +2 -2
- data/lib/consul/template/generator/configuration.rb +4 -0
- data/lib/consul/template/generator/init.rb +12 -6
- data/lib/consul/template/generator/version.rb +1 -1
- data/spec/init_spec.rb +2 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODY5MTY5NmE1MWZjZTUxZDNmYWQ0NjA5M2FjYjEzNzU1NTBiMTM4OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTFmNGE4OWRjNDQ5MDgyOTAyY2QwOTU4MTg2ZmNiM2IxMjg5NjE3Ng==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTFjMDM4ZDc3OTU5NmQ3ZDIyNGQ1ODMyZjY5OGQxYmYwMmM0NzMwODdmMjQw
|
10
|
+
MzUxOTNlMDdkMDAxODJhYjg2MTVlMTgzMDFhMTgyYTcwZWRkMjQ2MGU3MWNm
|
11
|
+
ZTkwZTJkYWQ5NTJlZGQ1ZmU3MzY5ZGM3NzY1NDIxYzY0MjBlOTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjY0NTliM2E5NDVkZTIzZTZjZjJhNjkzZGQ0ZGIwYTk2ZWZiNDU3ZGQwODM2
|
14
|
+
ZGI3MGYwYWMzZDZmMDlkNWZiOGJjZjc2MmE1NzY1NTdhNmRjNmY5OTVkMzcy
|
15
|
+
NTA5NjI4MjZmMjRlZWI3OGFkMTI0MzI4Mjk5YTRmNzEzMDBiYmM=
|
@@ -17,7 +17,7 @@ module Consul
|
|
17
17
|
@config = Consul::Template::Generator.config
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def configure_signal_handlers
|
21
21
|
Signal.trap("INT") do
|
22
22
|
@config.logger.error "Received INT signal..."
|
23
23
|
@interrupted = true
|
@@ -30,7 +30,7 @@ module Consul
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def run(cycle_sleep = nil, lock_sleep = nil)
|
33
|
-
|
33
|
+
configure_signal_handlers
|
34
34
|
@terminated = false
|
35
35
|
cycle_sleep ||= 0.5
|
36
36
|
lock_sleep ||= 1.0
|
@@ -5,28 +5,34 @@ module Consul
|
|
5
5
|
attr_accessor :session
|
6
6
|
|
7
7
|
def initialize(consul_session_id = nil, do_create_session = true)
|
8
|
+
@config = Consul::Template::Generator.config
|
8
9
|
if (consul_session_id.nil? && do_create_session)
|
9
10
|
create_session
|
10
11
|
else
|
11
12
|
@session = consul_session_id
|
12
13
|
end
|
13
|
-
@config = Consul::Template::Generator.config
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_session
|
17
17
|
unless @session.nil?
|
18
18
|
destroy_session
|
19
19
|
end
|
20
|
-
@session = Consul::Template::Generator.create_session
|
20
|
+
@session = Consul::Template::Generator.create_session @config.session_name
|
21
21
|
end
|
22
22
|
|
23
23
|
def destroy_session
|
24
|
+
attempts = 0
|
24
25
|
begin
|
25
|
-
Consul::Template::Generator.destroy_session @session
|
26
|
+
destroyed = Consul::Template::Generator.destroy_session @session
|
26
27
|
rescue
|
27
|
-
Consul::Template::Generator.config.logger.info "Failed to destroy session: #{@session}"
|
28
|
-
|
29
|
-
|
28
|
+
Consul::Template::Generator.config.logger.info "Failed to destroy session: #{@session}, attempt number #{attempts}"
|
29
|
+
ensure
|
30
|
+
@session = destroyed ? nil : @session
|
31
|
+
unless @session.nil?
|
32
|
+
attempts += 1
|
33
|
+
sleep 0.25
|
34
|
+
end
|
35
|
+
end until (destroyed || attempts > 4)
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
data/spec/init_spec.rb
CHANGED
@@ -11,6 +11,7 @@ describe 'Consul::Template::Generator::CTRunner' '#initialize' do
|
|
11
11
|
config.templates = {'test-session-template.ctmpl' => 'test-session-template' }
|
12
12
|
config.node = 'test-node'
|
13
13
|
config.log_level = :off
|
14
|
+
config.session_key = '/session/consul-template-generator'
|
14
15
|
config.consul_template_binary = 'consul-template'
|
15
16
|
end
|
16
17
|
end
|
@@ -41,7 +42,7 @@ describe 'Consul::Template::Generator::CTRunner' '#initialize' do
|
|
41
42
|
expect(runner.session).to eql('failed-destroyed-session')
|
42
43
|
runner.create_session
|
43
44
|
expect(WebMock).to have_requested(:put, 'http://127.0.0.1:8500/v1/session/create').with(:body => '{"Node":"test-node","Name":"consul-template-generator","Behavior":"release"}')
|
44
|
-
expect(WebMock).to have_requested(:put, 'http://127.0.0.1:8500/v1/session/destroy/failed-destroyed-session')
|
45
|
+
expect(WebMock).to have_requested(:put, 'http://127.0.0.1:8500/v1/session/destroy/failed-destroyed-session').times(5)
|
45
46
|
expect(runner.session).to eql('test-session-id')
|
46
47
|
end
|
47
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul-template-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Oldfield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -180,12 +180,12 @@ require_paths:
|
|
180
180
|
- lib
|
181
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
182
182
|
requirements:
|
183
|
-
- - '>='
|
183
|
+
- - ! '>='
|
184
184
|
- !ruby/object:Gem::Version
|
185
185
|
version: '0'
|
186
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
187
|
requirements:
|
188
|
-
- - '>='
|
188
|
+
- - ! '>='
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: '0'
|
191
191
|
requirements: []
|
@@ -201,4 +201,3 @@ test_files:
|
|
201
201
|
- spec/key_value_spec.rb
|
202
202
|
- spec/run_spec.rb
|
203
203
|
- spec/spec_helper.rb
|
204
|
-
has_rdoc:
|