copy_tuner_client 0.13.6 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/copy_tuner_client/process_guard.rb +20 -18
- data/lib/copy_tuner_client/version.rb +1 -1
- data/spec/copy_tuner_client/process_guard_spec.rb +0 -24
- metadata +2 -4
- data/spec/support/fake_resque_job.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b43b5c8067dd3666dccb82ed7a98df2ba4bc062c3f12d540fecfe74ac7988b72
|
4
|
+
data.tar.gz: 49d07a02e6f7db85afc39cf7bde5453231fe2ba112e29a7ed10581a4890d39dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4342ff5bea8a937980ab0e0656ae273d533803a07167c383761456addb425cadbe9712cfc0327474f8e4d35d04523bf5839c5dcb347a818aca4fdca33c36e9be
|
7
|
+
data.tar.gz: 0a8553e3ca6cf15b6a41c4ab4bc9e6b8c0150e8025c379d2fab9aa46618a6c960799fa8efada1b00a32ee2864a44c043c1282e7deace4019489aa0a1f62d1380
|
data/CHANGELOG.md
CHANGED
@@ -18,7 +18,6 @@ module CopyTunerClient
|
|
18
18
|
register_spawn_hooks
|
19
19
|
else
|
20
20
|
register_exit_hooks
|
21
|
-
register_job_hooks
|
22
21
|
start_polling
|
23
22
|
end
|
24
23
|
end
|
@@ -30,7 +29,7 @@ module CopyTunerClient
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def spawner?
|
33
|
-
passenger_spawner? || unicorn_spawner? || delayed_job_spawner? || puma_spawner?
|
32
|
+
passenger_spawner? || unicorn_spawner? || delayed_job_spawner? || puma_spawner? || good_job_spawner?
|
34
33
|
end
|
35
34
|
|
36
35
|
def passenger_spawner?
|
@@ -53,6 +52,10 @@ module CopyTunerClient
|
|
53
52
|
defined?(Delayed::Worker) && $0.include?('delayed_job')
|
54
53
|
end
|
55
54
|
|
55
|
+
def good_job_spawner?
|
56
|
+
$0.include?('good_job') && defined?(GoodJob) && ARGV.include?('--daemonize')
|
57
|
+
end
|
58
|
+
|
56
59
|
def register_spawn_hooks
|
57
60
|
if passenger_spawner?
|
58
61
|
register_passenger_hook
|
@@ -62,6 +65,8 @@ module CopyTunerClient
|
|
62
65
|
register_puma_hook
|
63
66
|
elsif delayed_job_spawner?
|
64
67
|
register_delayed_hook
|
68
|
+
elsif good_job_spawner?
|
69
|
+
register_good_job_hook
|
65
70
|
end
|
66
71
|
end
|
67
72
|
|
@@ -96,6 +101,18 @@ module CopyTunerClient
|
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
104
|
+
def register_good_job_hook
|
105
|
+
@logger.info("Registered good_job start hook")
|
106
|
+
poller = @poller
|
107
|
+
hook_module = Module.new do
|
108
|
+
define_method :daemon do
|
109
|
+
super() # NOTE: define_method 内で super を呼ぶ場合は引数を明示的に指定する必要があるので注意
|
110
|
+
poller.start
|
111
|
+
end
|
112
|
+
end
|
113
|
+
::Process.singleton_class.prepend hook_module
|
114
|
+
end
|
115
|
+
|
99
116
|
def register_puma_hook
|
100
117
|
# If Puma is clustered mode without preload_app, this method is called on worker process.
|
101
118
|
# Just start poller and return.
|
@@ -112,7 +129,7 @@ module CopyTunerClient
|
|
112
129
|
hook_module = Module.new do
|
113
130
|
define_method :start_server do
|
114
131
|
poller.start
|
115
|
-
super()
|
132
|
+
super() # NOTE: define_method 内で super を呼ぶ場合は引数を明示的に指定する必要があるので注意
|
116
133
|
end
|
117
134
|
end
|
118
135
|
Puma::Runner.prepend hook_module
|
@@ -123,20 +140,5 @@ module CopyTunerClient
|
|
123
140
|
@cache.flush
|
124
141
|
end
|
125
142
|
end
|
126
|
-
|
127
|
-
def register_job_hooks
|
128
|
-
if defined?(Resque::Job)
|
129
|
-
@logger.info("Registered Resque after_perform hook")
|
130
|
-
cache = @cache
|
131
|
-
Resque::Job.class_eval do
|
132
|
-
alias_method :perform_without_copy_tuner, :perform
|
133
|
-
define_method :perform do
|
134
|
-
job_was_performed = perform_without_copy_tuner
|
135
|
-
cache.flush
|
136
|
-
job_was_performed
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
143
|
end
|
142
144
|
end
|
@@ -91,28 +91,4 @@ describe CopyTunerClient::ProcessGuard do
|
|
91
91
|
|
92
92
|
expect(cache).to be_written
|
93
93
|
end
|
94
|
-
|
95
|
-
it "flushes after running a resque job" do
|
96
|
-
logger = FakeLogger.new
|
97
|
-
cache = WritingCache.new
|
98
|
-
define_constant('Resque', Module.new)
|
99
|
-
job_class = define_constant('Resque::Job', FakeResqueJob)
|
100
|
-
job = job_class.new
|
101
|
-
process_guard = build_process_guard(:cache => cache, :logger => logger)
|
102
|
-
|
103
|
-
process_guard.start
|
104
|
-
job.fork_and_perform
|
105
|
-
|
106
|
-
expect(cache).to be_written
|
107
|
-
expect(logger).to have_entry(:info, "Registered Resque after_perform hook")
|
108
|
-
end
|
109
|
-
|
110
|
-
it "doesn't fail if only Resque is defined and not Resque::Job" do
|
111
|
-
logger = FakeLogger.new
|
112
|
-
cache = WritingCache.new
|
113
|
-
define_constant('Resque', Module.new)
|
114
|
-
process_guard = build_process_guard(:cache => cache, :logger => logger)
|
115
|
-
|
116
|
-
process_guard.start
|
117
|
-
end
|
118
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copy_tuner_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -248,7 +248,6 @@ files:
|
|
248
248
|
- spec/support/fake_html_safe_string.rb
|
249
249
|
- spec/support/fake_logger.rb
|
250
250
|
- spec/support/fake_passenger.rb
|
251
|
-
- spec/support/fake_resque_job.rb
|
252
251
|
- spec/support/fake_unicorn.rb
|
253
252
|
- spec/support/middleware_stack.rb
|
254
253
|
- spec/support/writing_cache.rb
|
@@ -307,7 +306,6 @@ test_files:
|
|
307
306
|
- spec/support/fake_html_safe_string.rb
|
308
307
|
- spec/support/fake_logger.rb
|
309
308
|
- spec/support/fake_passenger.rb
|
310
|
-
- spec/support/fake_resque_job.rb
|
311
309
|
- spec/support/fake_unicorn.rb
|
312
310
|
- spec/support/middleware_stack.rb
|
313
311
|
- spec/support/writing_cache.rb
|