consul-templaterb 1.27.0 → 1.28.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -27
- data/README.md +18 -3
- data/TemplateAPI.md +1 -1
- data/bin/consul-templaterb +22 -6
- data/lib/consul/async/consul_template.rb +14 -8
- data/lib/consul/async/consul_template_render.rb +1 -1
- data/lib/consul/async/process_handler.rb +7 -1
- data/lib/consul/async/version.rb +1 -1
- data/samples/consul-ui/css/style.css +4 -0
- data/samples/consul-ui/decorators.js.erb +7 -0
- data/samples/consul-ui/js/nodes.js +2 -2
- data/samples/consul-ui/js/service.js +1 -1
- data/samples/consul-ui/js/utils.js +52 -24
- data/samples/prometheus_datacenter_coordinates.erb +56 -0
- metadata +33 -51
- data/.gitignore +0 -41
- data/.rspec +0 -2
- data/.rubocop.yml +0 -57
- data/.ruby_app +0 -0
- data/.travis.yml +0 -19
- data/CODE_OF_CONDUCT.md +0 -76
- data/CONTRIBUTING.md +0 -25
- data/Dockerfile +0 -15
- data/Gemfile +0 -5
- data/INTERNALS.md +0 -49
- data/LICENSE.txt +0 -201
- data/Rakefile +0 -8
- data/consul-templaterb.gemspec +0 -42
- data/docker-nginx-conf/nginx.conf +0 -27
- data/docs/article-06_Template-based_discovery_with_consul-templaterb.md +0 -124
- data/docs/images/consul-templaterb.png +0 -0
- data/docs/images/consul-templaterb.svg +0 -3
- data/docs/images/consul-ui_001.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b99b274e76706dd09a6da62555cc79c462d5072237825fb10fea80ef3d3e558
|
4
|
+
data.tar.gz: 68e4a32addfb0decb19e8dbda17dfc99665c6e19da03d789cddf61196c051c7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1385863a2b51bb12c4b900c869a82048acecec0abe9e6875e151cf39151e5f0ff983b130549191d236315c22ff45e61810c515397d75fe2847dc28e70044499
|
7
|
+
data.tar.gz: 9a6acde596746461c64b99145f13952e4e4cfc4ea009b9e31f65afab96f5e7ecf93f5764ad7d0e5fd98e5b37419bc5b60c169abf6aefdc5bb2cbbd55f1495c30
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,43 @@
|
|
2
2
|
|
3
3
|
## (UNRELEASED)
|
4
4
|
|
5
|
+
## 1.28.2 (Oct 5, 2020)
|
6
|
+
|
7
|
+
NEW FEATURES:
|
8
|
+
|
9
|
+
* Added new decorator to compute node names in consul-ui ([#70](https://github.com/criteo/consul-templaterb/pull/70))
|
10
|
+
|
11
|
+
## 1.28.1 (Sept 30, 2020)
|
12
|
+
|
13
|
+
IMPROVEMENTS:
|
14
|
+
|
15
|
+
* Reduced size of GEM from 400k o 100k by removing not needed files
|
16
|
+
|
17
|
+
## 1.28.0 (Sept 25, 2020)
|
18
|
+
|
19
|
+
NEW FEATURES:
|
20
|
+
|
21
|
+
* Added `-W` or `--wait-between-reload-signal` to avoid sending too many signals
|
22
|
+
to a process executed. This avoids for instance reloading too much a HAProxy configuration
|
23
|
+
without having to play with `-w` as described in [#69](https://github.com/criteo/consul-templaterb/issues/69)
|
24
|
+
|
25
|
+
BUG FIXES:
|
26
|
+
|
27
|
+
* Removed warnings at runtime with Ruby 2.7+
|
28
|
+
* Minor JS fix in Consul-UI (Added missing unused parameter to function `serviceTitleGenerator`)
|
29
|
+
|
30
|
+
## 1.27.2 (Sept 4, 2020)
|
31
|
+
|
32
|
+
IMPROVEMENTS:
|
33
|
+
|
34
|
+
* Consul-UI now supports navigation between nodes and services in both ways
|
35
|
+
|
36
|
+
## 1.27.1 (July 28, 2020)
|
37
|
+
|
38
|
+
BUGIX:
|
39
|
+
|
40
|
+
* Fix collision in JSON queries when using payload in requests [#68](https://github.com/criteo/consul-templaterb/pull/68)
|
41
|
+
|
5
42
|
## 1.27.0 (June 5, 2020)
|
6
43
|
|
7
44
|
NEW FEATURES:
|
@@ -13,15 +50,15 @@ NEW FEATURES:
|
|
13
50
|
|
14
51
|
## 1.26.3 (April 15, 2020)
|
15
52
|
|
16
|
-
|
53
|
+
BUG FIXES:
|
17
54
|
|
18
55
|
* Removed all Criteo specific decorators from Consul-UI
|
19
56
|
|
20
57
|
## 1.26.2 (April 15, 2020)
|
21
58
|
|
22
|
-
|
59
|
+
BUG FIXES:
|
23
60
|
|
24
|
-
* Fixed broken Dockerfile (was missing the new `decorator.js.erb` file). Fixes #61 (Thanks to @
|
61
|
+
* Fixed broken Dockerfile (was missing the new `decorator.js.erb` file). Fixes #61 (Thanks to [@simongareste](https://github.com/simongareste))
|
25
62
|
|
26
63
|
NEW FEATURES:
|
27
64
|
|
@@ -29,7 +66,7 @@ NEW FEATURES:
|
|
29
66
|
|
30
67
|
## 1.26.1 (March 27, 2020)
|
31
68
|
|
32
|
-
|
69
|
+
BUG FIXES:
|
33
70
|
|
34
71
|
* Using `agent: http://vault_or_consul_agent:port>` was not properly taken into account in some endpoints
|
35
72
|
|
@@ -47,7 +84,7 @@ NEW FEATURES:
|
|
47
84
|
|
48
85
|
## 1.25.2 (February 29, 2020)
|
49
86
|
|
50
|
-
|
87
|
+
BUG FIXES:
|
51
88
|
|
52
89
|
* Update rake to 12.3.3 to fix [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8)
|
53
90
|
|
@@ -66,7 +103,7 @@ NEW FEATURES:
|
|
66
103
|
|
67
104
|
## 1.24.1 (February 19, 2020)
|
68
105
|
|
69
|
-
|
106
|
+
BUG FIXES:
|
70
107
|
|
71
108
|
* Properly set service meta in node meta decorator
|
72
109
|
|
@@ -83,7 +120,7 @@ NEW FEATURES:
|
|
83
120
|
* Implementation of #59 - implementation of `--retry` and `--vault-retry` new flags
|
84
121
|
Those flags work in a similar way as in consul-template: stop program after X failures
|
85
122
|
of consul or vault endpoints
|
86
|
-
* Added
|
123
|
+
* Added `--fail-fast` that stop the programs immediately if vault or consul are not available
|
87
124
|
at startup (also works with `--once`)
|
88
125
|
|
89
126
|
## 1.22.0 (January 17, 2020)
|
@@ -94,7 +131,7 @@ NEW FEATURES:
|
|
94
131
|
|
95
132
|
## 1.21.8 (January 2, 2020)
|
96
133
|
|
97
|
-
|
134
|
+
BUG FIXES:
|
98
135
|
|
99
136
|
* Escape properly metadata containing double quotes in prometheus exporter
|
100
137
|
|
@@ -108,13 +145,13 @@ IMPROVEMENTS:
|
|
108
145
|
|
109
146
|
IMPROVEMENTS:
|
110
147
|
|
111
|
-
* Added node_meta_info for serviceInstanceDecorator and serviceMetaDecorator
|
148
|
+
* Added `node_meta_info` for `serviceInstanceDecorator` and `serviceMetaDecorator` in Consul-UI
|
112
149
|
|
113
150
|
## 1.21.5 (December 6, 2019)
|
114
151
|
|
115
152
|
NEW FEATURES:
|
116
153
|
|
117
|
-
* Added clean() method in nodes.js to allow
|
154
|
+
* Added `clean()` method in nodes.js to allow new behaviors
|
118
155
|
|
119
156
|
## 1.21.4 (November 28, 2019)
|
120
157
|
|
@@ -145,7 +182,7 @@ IMPROVEMENTS:
|
|
145
182
|
## 1.21.0 (November 21, 2019)
|
146
183
|
|
147
184
|
* added function `templates` to list all templates being rendered
|
148
|
-
* added support for JS decorators in consul-ui (thanks to @Thib17)
|
185
|
+
* added support for JS decorators in consul-ui (thanks to [@Thib17](https://github.com/Thib17))
|
149
186
|
|
150
187
|
## 1.20.0 (October 16, 2019)
|
151
188
|
|
@@ -164,7 +201,7 @@ NEW FEATURES:
|
|
164
201
|
|
165
202
|
* Added new function `checks_for_node`
|
166
203
|
|
167
|
-
|
204
|
+
BUG FIXES:
|
168
205
|
|
169
206
|
* Avoid try publishing several times Gem on rubygems.org
|
170
207
|
|
@@ -186,13 +223,13 @@ IMPROVEMENTS:
|
|
186
223
|
|
187
224
|
## 1.18.3 (September 2, 2019)
|
188
225
|
|
189
|
-
|
226
|
+
BUG FIXES:
|
190
227
|
|
191
228
|
* When vault receives at timeout, correctly reschedule it
|
192
229
|
|
193
230
|
## 1.18.2 (August 28, 2019)
|
194
231
|
|
195
|
-
|
232
|
+
BUG FIXES:
|
196
233
|
|
197
234
|
* In Consul UI, showing data from KV with markup was not properly handled
|
198
235
|
|
@@ -208,7 +245,7 @@ Support any request method for remote_resource.as_json (#41)
|
|
208
245
|
|
209
246
|
## 1.18.1 (July 27, 2019)
|
210
247
|
|
211
|
-
|
248
|
+
BUG FIXES:
|
212
249
|
|
213
250
|
Fixed wrong lazy initialization in `remote_resource.as_json` that
|
214
251
|
cause too many connections to be opened.
|
@@ -217,13 +254,13 @@ cause too many connections to be opened.
|
|
217
254
|
|
218
255
|
NEW FEATURES:
|
219
256
|
|
220
|
-
* Support for `remote_resource` provided by @kamaradclimber
|
257
|
+
* Support for `remote_resource` provided by [@kamaradclimber](https://github.com/kamaradclimber)
|
221
258
|
* Added support for `remote_resource.as_json` to fetch JSON remote resource from a web server
|
222
259
|
* Added `samples/list_ruby_versions_from_rubygems.txt.erb` to demonstrate usage
|
223
260
|
|
224
261
|
## 1.17.3 (July 18, 2019)
|
225
262
|
|
226
|
-
|
263
|
+
BUG FIXES:
|
227
264
|
|
228
265
|
* Added gem parallel as a dependency to allow `samples/prometheus_consul_coordinates.erb`
|
229
266
|
to work properly
|
@@ -348,7 +385,7 @@ NEW FEATURES:
|
|
348
385
|
|
349
386
|
## 1.10.1 (February 28, 2019)
|
350
387
|
|
351
|
-
|
388
|
+
BUG FIXES:
|
352
389
|
|
353
390
|
* Ensure that timeline sort properly events when healthchecks are removed (eg: maintenance)
|
354
391
|
|
@@ -371,7 +408,7 @@ IMPROVEMENTS:
|
|
371
408
|
|
372
409
|
## 1.9.8 (January 16, 2019)
|
373
410
|
|
374
|
-
|
411
|
+
BUG FIXES:
|
375
412
|
|
376
413
|
* When default value was the same as real value, endpoints were always marked as
|
377
414
|
dirty, thus rendering of templates did never succeed.
|
@@ -387,7 +424,7 @@ IMPROVEMENTS:
|
|
387
424
|
|
388
425
|
## 1.9.6 (January 15, 2019)
|
389
426
|
|
390
|
-
|
427
|
+
BUG FIXES:
|
391
428
|
|
392
429
|
* Keep connections open properly as it increase timeouts on Consul servers on
|
393
430
|
very large templates
|
@@ -398,7 +435,7 @@ IMPROVEMENTS:
|
|
398
435
|
|
399
436
|
## 1.9.5 (January 14, 2019)
|
400
437
|
|
401
|
-
|
438
|
+
BUG FIXES:
|
402
439
|
|
403
440
|
* Ensure to always re-open Connection to Consul agent in case of network error
|
404
441
|
|
@@ -448,11 +485,11 @@ IMPROVEMENTS:
|
|
448
485
|
|
449
486
|
OPTIMIZATIONS:
|
450
487
|
|
451
|
-
* Better network
|
488
|
+
* Better network usage because of X-Consul-Index parsing bug
|
452
489
|
|
453
|
-
|
490
|
+
BUG FIXES:
|
454
491
|
|
455
|
-
* value.endpoint.x_consul_index now works as expected
|
492
|
+
* `value.endpoint.x_consul_index` now works as expected
|
456
493
|
|
457
494
|
IMPROVEMENTS:
|
458
495
|
|
@@ -492,7 +529,7 @@ NEW FEATURES:
|
|
492
529
|
|
493
530
|
## 1.8.1 (December 12, 2018)
|
494
531
|
|
495
|
-
|
532
|
+
BUG FIXES:
|
496
533
|
|
497
534
|
* Properly fill `template_info` strtucture when hot reload is performed so templates using
|
498
535
|
`template_info()` new function can behave nicely.
|
@@ -601,8 +638,8 @@ IMPROVEMENTS:
|
|
601
638
|
* [Prometheus template](samples/metrics.erb) to export easily Consul
|
602
639
|
informations about nodes, datacenters and all services states
|
603
640
|
* Code style cleanup + travis now enforces Rubocop
|
604
|
-
* Remove criteo references in spec files thanks to @pierrecdn
|
605
|
-
* Bitrate display more consistent thanks to @pierrecdn
|
641
|
+
* Remove criteo references in spec files thanks to [@pierrecdn](https://github.com/pierrecdn)
|
642
|
+
* Bitrate display more consistent thanks to [@pierrecdn](https://github.com/pierrecdn)
|
606
643
|
|
607
644
|
## 1.5.3 (September 24, 2018)
|
608
645
|
|
data/README.md
CHANGED
@@ -165,9 +165,19 @@ USAGE: consul-templaterb [[options]]
|
|
165
165
|
-f, --[no-]fail-fast If consul/vault endpoints fail at startup, fail immediately
|
166
166
|
-g, --no-gzip-compression Disable GZIP compression in HTTP requests
|
167
167
|
-c, --consul-addr=<address> Address of Consul, eg: http://localhost:8500
|
168
|
+
--consul-cert-chain=<path/to/cert_chain>
|
169
|
+
Path to Consul TLS client certificate chain to use
|
170
|
+
--consul-private-key=<path/to/private_key>
|
171
|
+
Path to Consul TLS client private key to use
|
172
|
+
--skip-consul-verify-tls Skip verifying Consul TLS via certificate authority (DANGEROUS)
|
168
173
|
-l, --log-level=<log_level> Log level, default=info, any of none|error|info|debug
|
169
174
|
--consul-token=<token> Use a token to connect to Consul
|
170
175
|
-V, --vault-addr=<address> Address of Vault, eg: http://localhost:8200
|
176
|
+
--vault-cert-chain=<path/to/cert_chain>
|
177
|
+
Path to Vault TLS client certificate chain to use
|
178
|
+
--vault-private-key=<path/to/private_key>
|
179
|
+
Path to Vault TLS client private key to use
|
180
|
+
--skip-vault-verify-tls Skip verifying Vault TLS via certificate authority (DANGEROUS)
|
171
181
|
--vault-token=<token> Token used to authenticate against vault.
|
172
182
|
--[no-]vault-renew Control auto-renewal of the Vault token. Default: activated
|
173
183
|
--vault-retry, --vault-retry-attempts [RETRIES]
|
@@ -178,10 +188,11 @@ USAGE: consul-templaterb [[options]]
|
|
178
188
|
-r, --retry-delay=<min_duration> Min Retry delay on Error/Missing Consul Index
|
179
189
|
-k, --hot-reload=<behavior> Control hot reload behaviour, one of :[die (kill daemon on hot reload failure), keep (on error, keep running), disable (hot reload disabled)]
|
180
190
|
-K, --sig-term=kill_signal Signal to send to next --exec command on kill, default=TERM
|
191
|
+
-M, --debug-memory-usage Display messages when RAM grows
|
181
192
|
-T, --trim-mode=trim_mode ERB Trim mode to use (- by default)
|
182
193
|
-R, --sig-reload=reload_signal Signal to send to next --exec command on reload (NONE supported), default=HUP
|
183
|
-
-
|
184
|
-
-e, --exec=<command> Execute the following command
|
194
|
+
-W, --wait-signal=min_duration Wait at least n seconds before each reload signal being sent to next --exec process
|
195
|
+
-e, --exec=<command> Execute the following command in as a subprocess when all templates are ready
|
185
196
|
-d, --debug-network-usage Debug the network usage
|
186
197
|
-t erb_file:[output]:[command]:[params_file],
|
187
198
|
--template Add a erb template, its output and optional reload command
|
@@ -235,7 +246,11 @@ nor write the file.
|
|
235
246
|
Signals can be customized per process. Two signals are supported with options `--sig-reload` and
|
236
247
|
`--sig-term`. When the option is added, the next `--exec` options to start a process will use the
|
237
248
|
given signal. By default, HUP will be sent to reload events (you can use NONE to avoid sending any
|
238
|
-
reload signal), TERM will be used when leaving consul-templaterb.
|
249
|
+
reload signal), TERM will be used when leaving consul-templaterb. A minimum duration between reload
|
250
|
+
signals can be specified for each sub process by prepending `--wait-signal=min_duration` to `--exec`
|
251
|
+
command.
|
252
|
+
In such case, the signal will be sent every `min_duration` as a maximum (very useful for templates
|
253
|
+
changing a lot, but you don't want to trigger too many reloads, for instance for a load-balancer).
|
239
254
|
|
240
255
|
### Bandwidth limitation
|
241
256
|
|
data/TemplateAPI.md
CHANGED
@@ -388,7 +388,7 @@ name or its ID. If DC is specified, will lookup for given node in another datace
|
|
388
388
|
|
389
389
|
[Find all the checks](https://www.consul.io/api/health.html#list-checks-for-service) of a given service.
|
390
390
|
|
391
|
-
##
|
391
|
+
## checks_in_state(check_state, dc: nil, [agent: consul_agent_address])
|
392
392
|
|
393
393
|
[Find all the checks in a given state](https://www.consul.io/api-docs/health#list-checks-in-state) in the whole cluster.
|
394
394
|
|
data/bin/consul-templaterb
CHANGED
@@ -94,6 +94,7 @@ consul_engine = Consul::Async::ConsulTemplateEngine.new
|
|
94
94
|
@programs = {}
|
95
95
|
cur_sig_reload = 'HUP'.freeze
|
96
96
|
cur_sig_term = 'TERM'.freeze
|
97
|
+
cur_min_duration_between_signals = 1
|
97
98
|
|
98
99
|
optparse = OptionParser.new do |opts|
|
99
100
|
opts.banner = usage_text
|
@@ -215,6 +216,10 @@ optparse = OptionParser.new do |opts|
|
|
215
216
|
cur_sig_term = compute_signal(sig, nil)
|
216
217
|
end
|
217
218
|
|
219
|
+
opts.on('-M', '--debug-memory-usage', 'Display messages when RAM grows') do
|
220
|
+
consul_engine.debug_memory = true
|
221
|
+
end
|
222
|
+
|
218
223
|
opts.on('-T', '--trim-mode=trim_mode', String,
|
219
224
|
"ERB Trim mode to use (#{options[:erb][:trim_mode]} by default)") do |trim_mode|
|
220
225
|
options[:erb][:trim_mode] = trim_mode
|
@@ -225,25 +230,36 @@ optparse = OptionParser.new do |opts|
|
|
225
230
|
cur_sig_reload = compute_signal(sig, 'NONE')
|
226
231
|
end
|
227
232
|
|
228
|
-
opts.on('-
|
229
|
-
|
233
|
+
opts.on('-W', '--wait-signal=min_duration', Float, 'Wait at least n seconds before each reload signal being sent to next --exec process') do |min_duration|
|
234
|
+
raise "-wait-between-reload-signal=#{min_duration} must be greater than 0" unless min_duration.positive?
|
235
|
+
|
236
|
+
cur_min_duration_between_signals = min_duration
|
230
237
|
end
|
231
238
|
|
232
|
-
opts.on('-e', '--exec=<command>', String, 'Execute the following command') do |cmd|
|
239
|
+
opts.on('-e', '--exec=<command>', String, 'Execute the following command in as a subprocess when all templates are ready') do |cmd|
|
233
240
|
sig_reload = cur_sig_reload
|
234
241
|
sig_term = cur_sig_term
|
242
|
+
sig_min_interval = cur_min_duration_between_signals
|
235
243
|
consul_engine.add_template_callback do |all_ready, template_manager, results|
|
236
244
|
if all_ready
|
237
245
|
modified = results.any?(&:modified)
|
238
246
|
if @programs[cmd].nil?
|
239
|
-
warn "[EXEC] Starting process: #{cmd}... on_reload=#{sig_reload || 'NONE'} on_term=#{sig_term}"
|
247
|
+
warn "[EXEC] Starting process: #{cmd}... on_reload=#{sig_reload || 'NONE'} on_term=#{sig_term}, delay between reloads=#{sig_min_interval}s"
|
240
248
|
@programs[cmd] = Consul::Async::ProcessHandler.new(cmd, sig_reload: sig_reload, sig_term: sig_term)
|
241
249
|
@programs[cmd].start
|
242
250
|
else
|
251
|
+
|
243
252
|
# At least one template has been modified
|
244
|
-
@programs[cmd]
|
253
|
+
process_to_reload = @programs[cmd]
|
254
|
+
if modified && !process_to_reload.reload_scheduled
|
255
|
+
process_to_reload.reload_scheduled = true
|
256
|
+
now = Time.now
|
257
|
+
delay = sig_min_interval - (now - @programs[cmd].last_signal_sent)
|
258
|
+
delay = 0 if delay.negative?
|
259
|
+
EventMachine.add_timer(delay) { process_to_reload.reload }
|
260
|
+
end
|
245
261
|
begin
|
246
|
-
|
262
|
+
process_to_reload.process_status
|
247
263
|
rescue Consul::Async::ProcessDoesNotExist => e
|
248
264
|
warn "[FATAL] The process is dead, aborting run: #{e.inspect}"
|
249
265
|
template_manager.terminate
|
@@ -31,7 +31,8 @@ module Consul
|
|
31
31
|
|
32
32
|
def as_json(url, default_value, refresh_delay_secs: 10, **opts)
|
33
33
|
conf = JSONConfiguration.new(url: url, min_duration: refresh_delay_secs, retry_on_non_diff: refresh_delay_secs, **opts)
|
34
|
-
|
34
|
+
endpoint_id = url + opts.to_json
|
35
|
+
@endp_manager.create_if_missing(url, {}, endpoint_id: endpoint_id) do
|
35
36
|
if default_value.is_a?(Array)
|
36
37
|
ConsulTemplateJSONArray.new(JSONEndpoint.new(conf, url, default_value))
|
37
38
|
else
|
@@ -394,16 +395,21 @@ module Consul
|
|
394
395
|
VaultEndpoint.new(vault_conf, path, :POST, {}, {})
|
395
396
|
end
|
396
397
|
|
397
|
-
def create_if_missing(path, query_params, fail_fast_errors: @fail_fast_errors,
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
398
|
+
def create_if_missing(path, query_params, fail_fast_errors: @fail_fast_errors,
|
399
|
+
max_consecutive_errors_on_endpoint: @max_consecutive_errors_on_endpoint,
|
400
|
+
agent: nil, endpoint_id: nil)
|
401
|
+
endpoint_id ||= begin
|
402
|
+
fqdn = path.dup
|
403
|
+
query_params.each_pair do |k, v|
|
404
|
+
fqdn = "#{agent}#{fqdn}&#{k}=#{v}"
|
405
|
+
end
|
406
|
+
fqdn
|
407
|
+
end
|
408
|
+
tpl = @endpoints[endpoint_id]
|
403
409
|
unless tpl
|
404
410
|
tpl = yield
|
405
411
|
::Consul::Async::Debug.print_debug "path #{path.ljust(64)} #{query_params.inspect}\r"
|
406
|
-
@endpoints[
|
412
|
+
@endpoints[endpoint_id] = tpl
|
407
413
|
tpl.endpoint.on_response do |result|
|
408
414
|
@net_info[:success] += 1
|
409
415
|
@net_info[:bytes_read] += result.data.bytesize
|
@@ -59,7 +59,7 @@ module Consul
|
|
59
59
|
return false unless new_template != @template
|
60
60
|
|
61
61
|
# We render to ensure the template is valid
|
62
|
-
render(new_template, current_template_info)
|
62
|
+
render(new_template, current_template_info: current_template_info)
|
63
63
|
@template = new_template.freeze
|
64
64
|
true
|
65
65
|
end
|
@@ -7,7 +7,8 @@ module Consul
|
|
7
7
|
# Handle the full lifecycle of a process and allows to forward
|
8
8
|
# Posix signals to child process when needed.
|
9
9
|
class ProcessHandler
|
10
|
-
attr_reader :command, :sig_reload, :sig_term, :pid, :exit_status
|
10
|
+
attr_reader :command, :sig_reload, :sig_term, :pid, :exit_status, :last_signal_sent, :reload_scheduled
|
11
|
+
attr_writer :reload_scheduled
|
11
12
|
def initialize(command, sig_reload: 'HUP', sig_term: 'TERM')
|
12
13
|
raise 'empty sig_term is not supported' unless sig_term
|
13
14
|
|
@@ -16,18 +17,23 @@ module Consul
|
|
16
17
|
@sig_term = sig_term
|
17
18
|
@pid = nil
|
18
19
|
@exit_status = nil
|
20
|
+
@last_signal_sent = Time.now
|
21
|
+
@reload_scheduled = false
|
19
22
|
end
|
20
23
|
|
21
24
|
def start
|
22
25
|
return pid unless pid.nil?
|
23
26
|
|
24
27
|
@pid = Process.spawn(command)
|
28
|
+
@last_signal_sent = Time.now
|
25
29
|
end
|
26
30
|
|
27
31
|
def reload
|
28
32
|
return if sig_reload.nil?
|
29
33
|
|
34
|
+
@last_signal_sent = Time.now
|
30
35
|
warn "Sending SIG #{sig_reload} to #{pid}..."
|
36
|
+
@reload_scheduled = false
|
31
37
|
begin
|
32
38
|
Process.kill(sig_reload, pid)
|
33
39
|
rescue Errno::ESRCH => e
|