good_job 3.18.0 → 3.18.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 +30 -0
- data/app/models/good_job/batch.rb +4 -0
- data/lib/good_job/adapter.rb +2 -17
- data/lib/good_job/configuration.rb +30 -11
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +2 -0
- 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: 8210d74d5adf0f1c6f9a7d080fe855c9bbb4042d8c4e1c8349da9b26452ec629
|
4
|
+
data.tar.gz: 04c5daddea00fbb9a8eb6b068af973541790c7fec49bbd678a03e8e2eafc853b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2d6b3da26ea4fe01bff9e4a2ffa0830b34da0299af27e880a277703716fde024ca166bfa2203cf18cf53171523be9bca0754b21bba942e734506336a1020a5
|
7
|
+
data.tar.gz: 789e7565b789970c679beffef4a8f8c482469e1d027f97274bae0bf40709d94da08ded1e408011773a107880cd704402db6c6e964a363258b8d26ede29598def
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v3.18.2](https://github.com/bensheldon/good_job/tree/v3.18.2) (2023-09-02)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.18.1...v3.18.2)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Fix compatibility with Global ID v1.2.0 [\#1064](https://github.com/bensheldon/good_job/pull/1064) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Bump pg from 1.5.3 to 1.5.4 [\#1061](https://github.com/bensheldon/good_job/pull/1061) ([dependabot[bot]](https://github.com/apps/dependabot))
|
14
|
+
|
15
|
+
## [v3.18.1](https://github.com/bensheldon/good_job/tree/v3.18.1) (2023-08-30)
|
16
|
+
|
17
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.18.0...v3.18.1)
|
18
|
+
|
19
|
+
**Implemented enhancements:**
|
20
|
+
|
21
|
+
- Respect the configured execution mode, even within the CLI [\#1056](https://github.com/bensheldon/good_job/pull/1056) ([bensheldon](https://github.com/bensheldon))
|
22
|
+
|
23
|
+
**Closed issues:**
|
24
|
+
|
25
|
+
- Bug: calling `GoodJob.restart` in Puma on\_worker\_boot starts GoodJob regardless of it being in async mode or not [\#1054](https://github.com/bensheldon/good_job/issues/1054)
|
26
|
+
- \[Feature Request?\] Config Option to Inline Child-Jobs in Worker Processes [\#1052](https://github.com/bensheldon/good_job/issues/1052)
|
27
|
+
- \[Feature Request\] Hook to extend cron schedules [\#1050](https://github.com/bensheldon/good_job/issues/1050)
|
28
|
+
|
29
|
+
**Merged pull requests:**
|
30
|
+
|
31
|
+
- `GoodJob.restart` should not start capsules \(job execution\) when in a webserver but not in async mode [\#1055](https://github.com/bensheldon/good_job/pull/1055) ([bensheldon](https://github.com/bensheldon))
|
32
|
+
|
3
33
|
## [v3.18.0](https://github.com/bensheldon/good_job/tree/v3.18.0) (2023-08-30)
|
4
34
|
|
5
35
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.17.4...v3.18.0)
|
data/lib/good_job/adapter.rb
CHANGED
@@ -185,7 +185,7 @@ module GoodJob
|
|
185
185
|
# @return [Boolean]
|
186
186
|
def execute_async?
|
187
187
|
execution_mode == :async_all ||
|
188
|
-
(execution_mode.in?([:async, :async_server]) &&
|
188
|
+
(execution_mode.in?([:async, :async_server]) && GoodJob.configuration.in_webserver?)
|
189
189
|
end
|
190
190
|
|
191
191
|
# Whether in +:external+ execution mode.
|
@@ -193,7 +193,7 @@ module GoodJob
|
|
193
193
|
def execute_externally?
|
194
194
|
execution_mode.nil? ||
|
195
195
|
execution_mode == :external ||
|
196
|
-
(execution_mode.in?([:async, :async_server]) && !
|
196
|
+
(execution_mode.in?([:async, :async_server]) && !GoodJob.configuration.in_webserver?)
|
197
197
|
end
|
198
198
|
|
199
199
|
# Whether in +:inline+ execution mode.
|
@@ -219,21 +219,6 @@ module GoodJob
|
|
219
219
|
|
220
220
|
private
|
221
221
|
|
222
|
-
# Whether running in a web server process.
|
223
|
-
# @return [Boolean, nil]
|
224
|
-
def in_server_process?
|
225
|
-
return @_in_server_process if defined? @_in_server_process
|
226
|
-
|
227
|
-
@_in_server_process = Rails.const_defined?(:Server) || begin
|
228
|
-
self_caller = caller
|
229
|
-
|
230
|
-
self_caller.grep(%r{config.ru}).any? || # EXAMPLE: config.ru:3:in `block in <main>' OR config.ru:3:in `new_from_string'
|
231
|
-
self_caller.grep(%r{puma/request}).any? || # EXAMPLE: puma-5.6.4/lib/puma/request.rb:76:in `handle_request'
|
232
|
-
self_caller.grep(%{/rack/handler/}).any? || # EXAMPLE: iodine-0.7.44/lib/rack/handler/iodine.rb:13:in `start'
|
233
|
-
(Concurrent.on_jruby? && self_caller.grep(%r{jruby/rack/rails_booter}).any?) # EXAMPLE: uri:classloader:/jruby/rack/rails_booter.rb:83:in `load_environment'
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
222
|
def send_notify?(active_job)
|
238
223
|
return false unless GoodJob.configuration.enable_listen_notify
|
239
224
|
return true unless active_job.respond_to?(:good_job_notify)
|
@@ -79,6 +79,8 @@ module GoodJob
|
|
79
79
|
def initialize(options, env: ENV)
|
80
80
|
@options = options
|
81
81
|
@env = env
|
82
|
+
|
83
|
+
@_in_webserver = nil
|
82
84
|
end
|
83
85
|
|
84
86
|
def validate!
|
@@ -89,21 +91,24 @@ module GoodJob
|
|
89
91
|
# for more details on possible values.
|
90
92
|
# @return [Symbol]
|
91
93
|
def execution_mode
|
92
|
-
mode =
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
rails_config[:execution_mode] ||
|
97
|
-
env['GOOD_JOB_EXECUTION_MODE']
|
98
|
-
end
|
94
|
+
mode = options[:execution_mode] ||
|
95
|
+
rails_config[:execution_mode] ||
|
96
|
+
env['GOOD_JOB_EXECUTION_MODE']
|
97
|
+
mode = mode.to_sym if mode
|
99
98
|
|
100
99
|
if mode
|
101
|
-
mode
|
100
|
+
if GoodJob::CLI.within_exe? && [:async, :async_server].include?(mode)
|
101
|
+
:external
|
102
|
+
else
|
103
|
+
mode
|
104
|
+
end
|
105
|
+
elsif GoodJob::CLI.within_exe?
|
106
|
+
:external
|
102
107
|
elsif Rails.env.development?
|
103
108
|
:async
|
104
109
|
elsif Rails.env.test?
|
105
110
|
:inline
|
106
|
-
else
|
111
|
+
else # rubocop:disable Lint/DuplicateBranch
|
107
112
|
:external
|
108
113
|
end
|
109
114
|
end
|
@@ -173,7 +178,7 @@ module GoodJob
|
|
173
178
|
|
174
179
|
# The number of seconds to wait for jobs to finish when shutting down
|
175
180
|
# before stopping the thread. +-1+ is forever.
|
176
|
-
# @return [
|
181
|
+
# @return [Float]
|
177
182
|
def shutdown_timeout
|
178
183
|
(
|
179
184
|
options[:shutdown_timeout] ||
|
@@ -245,7 +250,7 @@ module GoodJob
|
|
245
250
|
|
246
251
|
# Number of jobs a {Scheduler} will execute before automatically cleaning up preserved jobs.
|
247
252
|
# Positive values will clean up after that many jobs have run, false or 0 will disable, and -1 will clean up after every job.
|
248
|
-
# @return [Integer, nil]
|
253
|
+
# @return [Integer, Boolean, nil]
|
249
254
|
def cleanup_interval_jobs
|
250
255
|
if rails_config.key?(:cleanup_interval_jobs)
|
251
256
|
value = rails_config[:cleanup_interval_jobs]
|
@@ -349,6 +354,20 @@ module GoodJob
|
|
349
354
|
rails_config[:dashboard_default_locale] || DEFAULT_DASHBOARD_DEFAULT_LOCALE
|
350
355
|
end
|
351
356
|
|
357
|
+
# Whether running in a web server process.
|
358
|
+
# @return [Boolean, nil]
|
359
|
+
def in_webserver?
|
360
|
+
return @_in_webserver unless @_in_webserver.nil?
|
361
|
+
|
362
|
+
@_in_webserver = Rails.const_defined?(:Server) || begin
|
363
|
+
self_caller = caller
|
364
|
+
self_caller.grep(%r{config.ru}).any? || # EXAMPLE: config.ru:3:in `block in <main>' OR config.ru:3:in `new_from_string'
|
365
|
+
self_caller.grep(%r{puma/request}).any? || # EXAMPLE: puma-5.6.4/lib/puma/request.rb:76:in `handle_request'
|
366
|
+
self_caller.grep(%{/rack/handler/}).any? || # EXAMPLE: iodine-0.7.44/lib/rack/handler/iodine.rb:13:in `start'
|
367
|
+
(Concurrent.on_jruby? && self_caller.grep(%r{jruby/rack/rails_booter}).any?) # EXAMPLE: uri:classloader:/jruby/rack/rails_booter.rb:83:in `load_environment'
|
368
|
+
end || false
|
369
|
+
end
|
370
|
+
|
352
371
|
private
|
353
372
|
|
354
373
|
def rails_config
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -151,6 +151,8 @@ module GoodJob
|
|
151
151
|
# @param timeout [Numeric] Seconds to wait for active threads to finish.
|
152
152
|
# @return [void]
|
153
153
|
def self.restart(timeout: -1)
|
154
|
+
return if configuration.execution_mode != :async && configuration.in_webserver?
|
155
|
+
|
154
156
|
_shutdown_all(Capsule.instances, :restart, timeout: timeout)
|
155
157
|
end
|
156
158
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: good_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.18.
|
4
|
+
version: 3.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|