process_settings 0.17.0 → 0.18.0.pre.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15a15a0c5c7ea497858038e4b4be06e63aea209c8e3033662c28963d19839d39
|
4
|
+
data.tar.gz: ba4e23e5216b60ecc7e5e999dcac7d1679c90fd2cf6b712624da9a04aa629c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44058ab68dbb74cdf889bd57ac0bff0324f35f4608a27f67623da3b17a8ee0b4f9bfef24311395e969f941db28c2a5137c79c3233db75659fcc9e1f4239797e1
|
7
|
+
data.tar.gz: 3310afc60c343999207561d0e2820dc6ff4e985f71b1e25b8402fe7f3f39c762dd560f83cf78a5ccd57fa937a13c9dfdb43f41e57e8aa3326eb3a63d05f628bd
|
@@ -8,6 +8,8 @@ require 'active_support/deprecation'
|
|
8
8
|
require 'process_settings/abstract_monitor'
|
9
9
|
require 'process_settings/targeted_settings'
|
10
10
|
require 'process_settings/hash_path'
|
11
|
+
require 'process_settings/helpers/watchdog'
|
12
|
+
require 'exception_handling'
|
11
13
|
|
12
14
|
module ProcessSettings
|
13
15
|
class FileMonitor < AbstractMonitor
|
@@ -24,6 +26,31 @@ module ProcessSettings
|
|
24
26
|
start_internal(enable_listen_thread?(environment))
|
25
27
|
end
|
26
28
|
|
29
|
+
def start_watchdog_thread(file_path = :missing)
|
30
|
+
if file_path == :missing
|
31
|
+
ActiveSupport::Deprecation.warn("ProcessEnvSetup.start_watchdog_thread with no arguments is deprecated")
|
32
|
+
file_path = ProcessSettings::Monitor.file_path
|
33
|
+
end
|
34
|
+
|
35
|
+
@watchdog_thread and raise ArgumentError, "watchdog thread already running!"
|
36
|
+
@watchdog_thread = Thread.new do
|
37
|
+
watchdog = ProcessSettings::Watchdog.new(file_path)
|
38
|
+
loop do
|
39
|
+
ExceptionHandling.ensure_safe("ProcessSettings::Watchdog thread") do
|
40
|
+
sleep(1.minute)
|
41
|
+
watchdog.check
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def stop_watchdog_thread
|
48
|
+
if @watchdog_thread
|
49
|
+
Thread.kill(@watchdog_thread)
|
50
|
+
@watchdog_thread = nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
27
54
|
def start
|
28
55
|
start_internal(enable_listen_thread?)
|
29
56
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/numeric/time'
|
4
|
+
|
5
|
+
module ProcessSettings
|
6
|
+
class Watchdog
|
7
|
+
class OutOfSync < StandardError; end
|
8
|
+
|
9
|
+
MAX_MTIME_DIFFERENCE = 2.minutes
|
10
|
+
|
11
|
+
def initialize(process_settings_file_path)
|
12
|
+
@process_settings_file_path = process_settings_file_path or raise ArgumentError, "process_settings_file_path must be passed"
|
13
|
+
end
|
14
|
+
|
15
|
+
def check
|
16
|
+
if version_from_memory != version_from_disk && (Time.now - mtime_from_disk) > MAX_MTIME_DIFFERENCE
|
17
|
+
raise ProcessSettings::OutOfSync.new("ProcessSettings versions are out of sync!\n Version from Disk: #{version_from_disk}\n Version from Memory: #{version_from_memory}\n mtime of file: #{mtime_from_disk}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :process_settings_file_path
|
24
|
+
|
25
|
+
def version_from_memory
|
26
|
+
ProcessSettings.instance.untargeted_settings.version
|
27
|
+
end
|
28
|
+
|
29
|
+
def version_from_disk
|
30
|
+
ProcessSettings::TargetedSettings.from_file(process_settings_file_path, only_meta: true).version
|
31
|
+
end
|
32
|
+
|
33
|
+
def mtime_from_disk
|
34
|
+
File.mtime(process_settings_file_path)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -46,7 +46,7 @@ module ProcessSettings
|
|
46
46
|
def logger=(new_logger)
|
47
47
|
ActiveSupport::Deprecation.warn("ProcessSettings::Monitor.logger is deprecated and will be removed in v1.0.")
|
48
48
|
@logger = new_logger
|
49
|
-
Listen.logger
|
49
|
+
Listen.logger = new_logger unless Listen.instance_variable_get(:@logger)
|
50
50
|
end
|
51
51
|
|
52
52
|
deprecate :logger, :logger=, :file_path, :file_path=, deprecator: ActiveSupport::Deprecation.new('1.0', 'ProcessSettings')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/process_settings/file_monitor.rb
|
95
95
|
- lib/process_settings/hash_path.rb
|
96
96
|
- lib/process_settings/hash_with_hash_path.rb
|
97
|
+
- lib/process_settings/helpers/watchdog.rb
|
97
98
|
- lib/process_settings/monitor.rb
|
98
99
|
- lib/process_settings/replace_versioned_file.rb
|
99
100
|
- lib/process_settings/settings.rb
|
@@ -122,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
123
|
version: '0'
|
123
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
125
|
requirements:
|
125
|
-
- - "
|
126
|
+
- - ">"
|
126
127
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
128
|
+
version: 1.3.1
|
128
129
|
requirements: []
|
129
130
|
rubygems_version: 3.0.3
|
130
131
|
signing_key:
|