config_skeleton 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 +4 -4
- data/config_skeleton.gemspec +1 -1
- data/lib/config_skeleton.rb +20 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a58d74e2627a2f4f0ac79fa05c9ce07d2b17b8500af7e38d59fd7a33ac22fe7
|
4
|
+
data.tar.gz: 8b1d8531cc3fcc1183d14c465b886833b97130326d891b9da00ef05780b36a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351a846e41802b033bb217d3a574a5a8a18633cc51845313d15ef41220c036a92d068a6959fde5eea4fb25b8586974baf6e02ea62369342d911de5023bcc0863
|
7
|
+
data.tar.gz: ebbf67d572a03b463b40e0e359446fd1e76d64ad4a0200556ffb78a425130aebf0876c23b0090e9770c9b6921a0e370d22d9e11520ad875b12b59d95671d4e2b
|
data/config_skeleton.gemspec
CHANGED
data/lib/config_skeleton.rb
CHANGED
@@ -23,7 +23,8 @@ require 'tempfile'
|
|
23
23
|
#
|
24
24
|
# 1. Implement service-specific config generation and reloading code, by
|
25
25
|
# overriding the private methods #config_file, #config_data, and #reload_server
|
26
|
-
# (and also potentially #config_ok
|
26
|
+
# (and also potentially #config_ok?, #sleep_duration, #before_regenerate_config, and
|
27
|
+
# #after_regenerate_config).
|
27
28
|
# See the documentation for those methods for what they need to do.
|
28
29
|
#
|
29
30
|
# 1. Setup any file watchers you want with .watch and #watch.
|
@@ -362,6 +363,20 @@ class ConfigSkeleton < ServiceSkeleton
|
|
362
363
|
raise NotImplementedError, "config_data must be implemented in subclass."
|
363
364
|
end
|
364
365
|
|
366
|
+
# Run code before the config is regenerated and the config_file
|
367
|
+
# is written.
|
368
|
+
#
|
369
|
+
# @note this can optionally be implemented by subclasses.
|
370
|
+
#
|
371
|
+
def before_regenerate_config(force_reload); end
|
372
|
+
|
373
|
+
# Run code after the config is regenerated and if the regeneration
|
374
|
+
# was forced the new config has been cycled in.
|
375
|
+
#
|
376
|
+
# @note this can optionally be implemented by subclasses.
|
377
|
+
#
|
378
|
+
def after_regenerate_config(force_reload); end
|
379
|
+
|
365
380
|
# Verify that the currently running config is acceptable.
|
366
381
|
#
|
367
382
|
# In the event that a generated config is "bad", it may be possible to detect
|
@@ -443,6 +458,8 @@ class ConfigSkeleton < ServiceSkeleton
|
|
443
458
|
# @return [void]
|
444
459
|
#
|
445
460
|
def regenerate_config(force_reload: false)
|
461
|
+
before_regenerate_config(force_reload)
|
462
|
+
|
446
463
|
logger.debug(logloc) { "force? #{force_reload.inspect}" }
|
447
464
|
tmpfile = Tempfile.new(service_name, File.dirname(config_file))
|
448
465
|
logger.debug(logloc) { "Tempfile is #{tmpfile.path}" }
|
@@ -466,6 +483,8 @@ class ConfigSkeleton < ServiceSkeleton
|
|
466
483
|
cycle_config(tmpfile.path)
|
467
484
|
end
|
468
485
|
end
|
486
|
+
|
487
|
+
after_regenerate_config(force_reload)
|
469
488
|
ensure
|
470
489
|
metrics.last_change_timestamp.set({}, File.stat(config_file).mtime.to_f)
|
471
490
|
tmpfile.close rescue nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_skeleton
|
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
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|