process_settings 0.11.0.pre.4 → 0.11.0.pre.5
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/lib/process_settings/file_monitor.rb +31 -22
- data/lib/process_settings/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ada8f710e24244a34005a22536e106cf086863b110d1908f58503df01797dedb
|
4
|
+
data.tar.gz: ae8fa6f78f2d4894a81f4e806b8408790520c38b0a19df723fe4a572eb3ffea4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f58df6d01c42db7ec61b2c2815d3fdbe9cc8552e754edcad4e40a63816bbb6a621290acf2c0c636f87902e8fc10f28fc5330e4fd7250f8755e7d4c22f090304
|
7
|
+
data.tar.gz: 5a9ef3528655fbe57d3d23d9a2714fdc3223f9cc7234237cd20beb0f26891571f444d5a325bc2df1d9bfbff8e117b67ad769c797b2033c838c88064dc1bb567c
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'active_support'
|
4
4
|
require 'listen'
|
5
5
|
require 'psych'
|
6
|
+
require 'active_support/deprecation'
|
6
7
|
|
7
8
|
require 'process_settings/abstract_monitor'
|
8
9
|
require 'process_settings/targeted_settings'
|
@@ -20,32 +21,40 @@ module ProcessSettings
|
|
20
21
|
@untargeted_settings = nil
|
21
22
|
@last_untargetted_settings = nil
|
22
23
|
|
23
|
-
|
24
|
+
start_internal(enable_listen_thread?)
|
24
25
|
end
|
25
26
|
|
26
|
-
# starts listening for changes
|
27
|
-
# Note: This method creates a new thread that will be monitoring for changes
|
28
|
-
# do to the nature of how the Listen gem works, there is no record of
|
29
|
-
# existing threads, calling this mutliple times will result in spinning off
|
30
|
-
# multiple listen threads and will have unknow effects
|
31
27
|
def start
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# 1. set up file watcher
|
36
|
-
# 2. start it (this should trigger if any changes have been made since (1))
|
37
|
-
# 3. load the file
|
28
|
+
start_internal(enable_listen_thread?)
|
29
|
+
end
|
30
|
+
deprecate :start, deprecator: ActiveSupport::Deprecation.new('1.0', 'ProcessSettings') # will become private
|
38
31
|
|
39
|
-
|
40
|
-
if modified.include?(file_path) || added.include?(file_path)
|
41
|
-
logger.info("ProcessSettings::Monitor file #{file_path} changed. Reloading.")
|
42
|
-
load_untargeted_settings
|
32
|
+
private
|
43
33
|
|
44
|
-
|
34
|
+
# optionally starts listening for changes, then loads current settings
|
35
|
+
# Note: If with_listen_thread is truthy, this method creates a new thread that will be
|
36
|
+
# monitoring for changes.
|
37
|
+
# Due to how the Listen gem works, there is no record of
|
38
|
+
# existing threads; calling this multiple times will result in spinning off
|
39
|
+
# multiple listen threads and will have unknown effects.
|
40
|
+
def start_internal(with_listen_thread)
|
41
|
+
if with_listen_thread
|
42
|
+
path = File.dirname(file_path)
|
43
|
+
|
44
|
+
# to eliminate any race condition:
|
45
|
+
# 1. set up file watcher
|
46
|
+
# 2. start it (this should trigger if any changes have been made since (1))
|
47
|
+
# 3. load the file
|
48
|
+
|
49
|
+
@listener = file_change_notifier.to(path) do |modified, added, _removed|
|
50
|
+
if modified.include?(file_path) || added.include?(file_path)
|
51
|
+
logger.info("ProcessSettings::Monitor file #{file_path} changed. Reloading.")
|
52
|
+
load_untargeted_settings
|
53
|
+
|
54
|
+
load_statically_targeted_settings
|
55
|
+
end
|
45
56
|
end
|
46
|
-
end
|
47
57
|
|
48
|
-
if enable_listen_thread?
|
49
58
|
@listener.start
|
50
59
|
end
|
51
60
|
|
@@ -75,10 +84,10 @@ module ProcessSettings
|
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
78
|
-
private
|
79
|
-
|
80
87
|
def service_env
|
81
|
-
|
88
|
+
if defined?(Rails) && Rails.respond_to(:env)
|
89
|
+
Rails.env
|
90
|
+
end || ENV['SERVICE_ENV']
|
82
91
|
end
|
83
92
|
|
84
93
|
# Loads the most recent settings from disk
|