good_job 3.2.0 → 3.3.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 +63 -8
- data/README.md +28 -30
- data/app/assets/good_job/modules/application.js +2 -0
- data/app/assets/good_job/modules/popovers.js +7 -0
- data/app/assets/good_job/style.css +4 -0
- data/app/helpers/good_job/application_helper.rb +2 -2
- data/{lib → app/models/concerns}/good_job/filterable.rb +0 -0
- data/app/models/concerns/good_job/reportable.rb +43 -0
- data/{lib → app}/models/good_job/active_job_job.rb +0 -0
- data/{lib → app}/models/good_job/base_record.rb +0 -0
- data/{lib → app}/models/good_job/cron_entry.rb +1 -1
- data/{lib → app}/models/good_job/execution.rb +1 -39
- data/{lib → app/models}/good_job/execution_result.rb +0 -0
- data/{lib → app}/models/good_job/job.rb +2 -27
- data/{lib → app}/models/good_job/lockable.rb +0 -0
- data/{lib → app}/models/good_job/process.rb +4 -0
- data/app/views/good_job/cron_entries/index.html.erb +60 -57
- data/app/views/good_job/jobs/_executions.erb +31 -28
- data/app/views/good_job/jobs/_table.erb +138 -109
- data/app/views/good_job/jobs/show.html.erb +40 -31
- data/app/views/good_job/processes/index.html.erb +60 -32
- data/app/views/good_job/shared/_navbar.erb +1 -1
- data/app/views/good_job/shared/icons/_dots.html.erb +3 -0
- data/app/views/good_job/shared/icons/_info.html.erb +4 -0
- data/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb +4 -4
- data/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb +4 -4
- data/lib/good_job/adapter.rb +19 -12
- data/lib/good_job/cli.rb +4 -4
- data/lib/good_job/configuration.rb +6 -1
- data/lib/good_job/daemon.rb +2 -2
- data/lib/good_job/enqueuing.rb +4 -0
- data/lib/good_job/notifier.rb +1 -0
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +29 -14
- metadata +20 -30
- data/lib/good_job/active_job_extensions.rb +0 -5
data/lib/good_job/adapter.rb
CHANGED
@@ -25,10 +25,10 @@ module GoodJob
|
|
25
25
|
# - +production+ and all other environments: +:external+
|
26
26
|
#
|
27
27
|
def initialize(execution_mode: nil)
|
28
|
-
@
|
29
|
-
@
|
30
|
-
self.class.instances << self
|
28
|
+
@_execution_mode_override = execution_mode
|
29
|
+
GoodJob::Configuration.validate_execution_mode(@_execution_mode_override) if @_execution_mode_override
|
31
30
|
|
31
|
+
self.class.instances << self
|
32
32
|
start_async if GoodJob.async_ready?
|
33
33
|
end
|
34
34
|
|
@@ -82,7 +82,7 @@ module GoodJob
|
|
82
82
|
# @return [void]
|
83
83
|
def shutdown(timeout: :default)
|
84
84
|
timeout = if timeout == :default
|
85
|
-
|
85
|
+
GoodJob.configuration.shutdown_timeout
|
86
86
|
else
|
87
87
|
timeout
|
88
88
|
end
|
@@ -92,24 +92,31 @@ module GoodJob
|
|
92
92
|
@_async_started = false
|
93
93
|
end
|
94
94
|
|
95
|
+
# This adapter's execution mode
|
96
|
+
# @return [Symbol, nil]
|
97
|
+
def execution_mode
|
98
|
+
@_execution_mode_override || GoodJob.configuration.execution_mode
|
99
|
+
end
|
100
|
+
|
95
101
|
# Whether in +:async+ execution mode.
|
96
102
|
# @return [Boolean]
|
97
103
|
def execute_async?
|
98
|
-
|
99
|
-
(
|
104
|
+
execution_mode == :async_all ||
|
105
|
+
(execution_mode.in?([:async, :async_server]) && in_server_process?)
|
100
106
|
end
|
101
107
|
|
102
108
|
# Whether in +:external+ execution mode.
|
103
109
|
# @return [Boolean]
|
104
110
|
def execute_externally?
|
105
|
-
|
106
|
-
|
111
|
+
execution_mode.nil? ||
|
112
|
+
execution_mode == :external ||
|
113
|
+
(execution_mode.in?([:async, :async_server]) && !in_server_process?)
|
107
114
|
end
|
108
115
|
|
109
116
|
# Whether in +:inline+ execution mode.
|
110
117
|
# @return [Boolean]
|
111
118
|
def execute_inline?
|
112
|
-
|
119
|
+
execution_mode == :inline
|
113
120
|
end
|
114
121
|
|
115
122
|
# Start async executors
|
@@ -118,12 +125,12 @@ module GoodJob
|
|
118
125
|
return unless execute_async?
|
119
126
|
|
120
127
|
@notifier = GoodJob::Notifier.new
|
121
|
-
@poller = GoodJob::Poller.new(poll_interval:
|
122
|
-
@scheduler = GoodJob::Scheduler.from_configuration(
|
128
|
+
@poller = GoodJob::Poller.new(poll_interval: GoodJob.configuration.poll_interval)
|
129
|
+
@scheduler = GoodJob::Scheduler.from_configuration(GoodJob.configuration, warm_cache_on_initialize: true)
|
123
130
|
@notifier.recipients << [@scheduler, :create_thread]
|
124
131
|
@poller.recipients << [@scheduler, :create_thread]
|
125
132
|
|
126
|
-
@cron_manager = GoodJob::CronManager.new(
|
133
|
+
@cron_manager = GoodJob::CronManager.new(GoodJob.configuration.cron_entries, start_on_initialize: true) if GoodJob.configuration.enable_cron?
|
127
134
|
|
128
135
|
@_async_started = true
|
129
136
|
end
|
data/lib/good_job/cli.rb
CHANGED
@@ -85,7 +85,8 @@ module GoodJob
|
|
85
85
|
|
86
86
|
def start
|
87
87
|
set_up_application!
|
88
|
-
|
88
|
+
GoodJob.configuration.options.merge!(options.symbolize_keys)
|
89
|
+
configuration = GoodJob.configuration
|
89
90
|
|
90
91
|
Daemon.new(pidfile: configuration.pidfile).daemonize if configuration.daemonize?
|
91
92
|
|
@@ -142,10 +143,9 @@ module GoodJob
|
|
142
143
|
|
143
144
|
def cleanup_preserved_jobs
|
144
145
|
set_up_application!
|
146
|
+
GoodJob.configuration.options.merge!(options.symbolize_keys)
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
-
GoodJob.cleanup_preserved_jobs(older_than: configuration.cleanup_preserved_jobs_before_seconds_ago)
|
148
|
+
GoodJob.cleanup_preserved_jobs(older_than: GoodJob.configuration.cleanup_preserved_jobs_before_seconds_ago)
|
149
149
|
end
|
150
150
|
|
151
151
|
no_commands do
|
@@ -27,7 +27,12 @@ module GoodJob
|
|
27
27
|
# Default to not running cron
|
28
28
|
DEFAULT_ENABLE_CRON = false
|
29
29
|
|
30
|
+
def self.validate_execution_mode(execution_mode)
|
31
|
+
raise ArgumentError, "GoodJob execution mode must be one of #{EXECUTION_MODES.join(', ')}. It was '#{execution_mode}' which is not valid." unless execution_mode.in?(EXECUTION_MODES)
|
32
|
+
end
|
33
|
+
|
30
34
|
# The options that were explicitly set when initializing +Configuration+.
|
35
|
+
# It is safe to modify this hash in place; be sure to symbolize keys.
|
31
36
|
# @return [Hash]
|
32
37
|
attr_reader :options
|
33
38
|
|
@@ -47,7 +52,7 @@ module GoodJob
|
|
47
52
|
end
|
48
53
|
|
49
54
|
def validate!
|
50
|
-
|
55
|
+
self.class.validate_execution_mode(execution_mode)
|
51
56
|
end
|
52
57
|
|
53
58
|
# Specifies how and where jobs should be executed. See {Adapter#initialize}
|
data/lib/good_job/daemon.rb
CHANGED
@@ -26,7 +26,7 @@ module GoodJob
|
|
26
26
|
# @return [void]
|
27
27
|
def write_pid
|
28
28
|
File.open(pidfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY) { |f| f.write(::Process.pid.to_s) }
|
29
|
-
at_exit { File.delete(pidfile) if File.exist?(pidfile) }
|
29
|
+
at_exit { File.delete(pidfile) if File.exist?(pidfile) } # rubocop:disable Lint/NonAtomicFileOperation
|
30
30
|
rescue Errno::EEXIST
|
31
31
|
check_pid
|
32
32
|
retry
|
@@ -34,7 +34,7 @@ module GoodJob
|
|
34
34
|
|
35
35
|
# @return [void]
|
36
36
|
def delete_pid
|
37
|
-
File.delete(pidfile) if File.exist?(pidfile)
|
37
|
+
File.delete(pidfile) if File.exist?(pidfile) # rubocop:disable Lint/NonAtomicFileOperation
|
38
38
|
end
|
39
39
|
|
40
40
|
# @return [void]
|
data/lib/good_job/notifier.rb
CHANGED
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -2,19 +2,29 @@
|
|
2
2
|
require "active_job"
|
3
3
|
require "active_job/queue_adapters"
|
4
4
|
|
5
|
-
require "
|
6
|
-
zeitwerk_options = Gem::Version.new(Zeitwerk::VERSION) >= Gem::Version.new("2.6.0") ? { warn_on_extra_files: false } : {}
|
7
|
-
Zeitwerk::Loader.for_gem(**zeitwerk_options).tap do |loader|
|
8
|
-
loader.inflector.inflect({
|
9
|
-
"cli" => "CLI",
|
10
|
-
})
|
11
|
-
loader.push_dir("#{__dir__}/models")
|
12
|
-
loader.ignore("#{__dir__}/generators")
|
13
|
-
loader.setup
|
14
|
-
end
|
15
|
-
|
5
|
+
require "good_job/version"
|
16
6
|
require "good_job/engine"
|
17
7
|
|
8
|
+
require "good_job/adapter"
|
9
|
+
require "active_job/queue_adapters/good_job_adapter"
|
10
|
+
require "good_job/active_job_extensions/concurrency"
|
11
|
+
|
12
|
+
require "good_job/assignable_connection"
|
13
|
+
require "good_job/cleanup_tracker"
|
14
|
+
require "good_job/cli"
|
15
|
+
require "good_job/configuration"
|
16
|
+
require "good_job/cron_manager"
|
17
|
+
require 'good_job/current_thread'
|
18
|
+
require "good_job/daemon"
|
19
|
+
require "good_job/dependencies"
|
20
|
+
require "good_job/job_performer"
|
21
|
+
require "good_job/log_subscriber"
|
22
|
+
require "good_job/multi_scheduler"
|
23
|
+
require "good_job/notifier"
|
24
|
+
require "good_job/poller"
|
25
|
+
require "good_job/probe_server"
|
26
|
+
require "good_job/scheduler"
|
27
|
+
|
18
28
|
# GoodJob is a multithreaded, Postgres-based, ActiveJob backend for Ruby on Rails.
|
19
29
|
#
|
20
30
|
# +GoodJob+ is the top-level namespace and exposes configuration attributes.
|
@@ -69,6 +79,12 @@ module GoodJob
|
|
69
79
|
# @return [Proc, nil]
|
70
80
|
mattr_accessor :on_thread_error, default: nil
|
71
81
|
|
82
|
+
# @!attribute [rw] configuration
|
83
|
+
# @!scope class
|
84
|
+
# Global configuration object for GoodJob.
|
85
|
+
# @return [GoodJob::Configuration, nil]
|
86
|
+
mattr_accessor :configuration, default: GoodJob::Configuration.new({})
|
87
|
+
|
72
88
|
# Called with exception when a GoodJob thread raises an exception
|
73
89
|
# @param exception [Exception] Exception that was raised
|
74
90
|
# @return [void]
|
@@ -135,10 +151,9 @@ module GoodJob
|
|
135
151
|
# @params older_than [nil,Numeric,ActiveSupport::Duration] Jobs older than this will be destroyed (default: +86400+).
|
136
152
|
# @return [Integer] Number of jobs that were destroyed.
|
137
153
|
def self.cleanup_preserved_jobs(older_than: nil)
|
138
|
-
|
139
|
-
older_than ||= configuration.cleanup_preserved_jobs_before_seconds_ago
|
154
|
+
older_than ||= GoodJob.configuration.cleanup_preserved_jobs_before_seconds_ago
|
140
155
|
timestamp = Time.current - older_than
|
141
|
-
include_discarded = configuration.cleanup_discarded_jobs?
|
156
|
+
include_discarded = GoodJob.configuration.cleanup_discarded_jobs?
|
142
157
|
|
143
158
|
ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload|
|
144
159
|
old_jobs = GoodJob::Job.where('finished_at <= ?', timestamp)
|
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.2
|
4
|
+
version: 3.3.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: 2022-07-
|
11
|
+
date: 2022-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.3'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: zeitwerk
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '2.0'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '2.0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: benchmark-ips
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,16 +154,16 @@ dependencies:
|
|
168
154
|
name: dotenv
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
|
-
- - "
|
157
|
+
- - "~>"
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
159
|
+
version: 2.7.6
|
174
160
|
type: :development
|
175
161
|
prerelease: false
|
176
162
|
version_requirements: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
|
-
- - "
|
164
|
+
- - "~>"
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
166
|
+
version: 2.7.6
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: foreman
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -365,6 +351,7 @@ files:
|
|
365
351
|
- app/assets/good_job/modules/checkbox_toggle.js
|
366
352
|
- app/assets/good_job/modules/document_ready.js
|
367
353
|
- app/assets/good_job/modules/live_poll.js
|
354
|
+
- app/assets/good_job/modules/popovers.js
|
368
355
|
- app/assets/good_job/modules/toasts.js
|
369
356
|
- app/assets/good_job/scripts.js
|
370
357
|
- app/assets/good_job/style.css
|
@@ -382,6 +369,16 @@ files:
|
|
382
369
|
- app/filters/good_job/base_filter.rb
|
383
370
|
- app/filters/good_job/jobs_filter.rb
|
384
371
|
- app/helpers/good_job/application_helper.rb
|
372
|
+
- app/models/concerns/good_job/filterable.rb
|
373
|
+
- app/models/concerns/good_job/reportable.rb
|
374
|
+
- app/models/good_job/active_job_job.rb
|
375
|
+
- app/models/good_job/base_record.rb
|
376
|
+
- app/models/good_job/cron_entry.rb
|
377
|
+
- app/models/good_job/execution.rb
|
378
|
+
- app/models/good_job/execution_result.rb
|
379
|
+
- app/models/good_job/job.rb
|
380
|
+
- app/models/good_job/lockable.rb
|
381
|
+
- app/models/good_job/process.rb
|
385
382
|
- app/views/good_job/cron_entries/index.html.erb
|
386
383
|
- app/views/good_job/cron_entries/show.html.erb
|
387
384
|
- app/views/good_job/jobs/_executions.erb
|
@@ -398,7 +395,9 @@ files:
|
|
398
395
|
- app/views/good_job/shared/icons/_check.html.erb
|
399
396
|
- app/views/good_job/shared/icons/_clock.html.erb
|
400
397
|
- app/views/good_job/shared/icons/_dash_circle.html.erb
|
398
|
+
- app/views/good_job/shared/icons/_dots.html.erb
|
401
399
|
- app/views/good_job/shared/icons/_exclamation.html.erb
|
400
|
+
- app/views/good_job/shared/icons/_info.html.erb
|
402
401
|
- app/views/good_job/shared/icons/_play.html.erb
|
403
402
|
- app/views/good_job/shared/icons/_skip_forward.html.erb
|
404
403
|
- app/views/good_job/shared/icons/_stop.html.erb
|
@@ -416,7 +415,6 @@ files:
|
|
416
415
|
- lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb
|
417
416
|
- lib/generators/good_job/update_generator.rb
|
418
417
|
- lib/good_job.rb
|
419
|
-
- lib/good_job/active_job_extensions.rb
|
420
418
|
- lib/good_job/active_job_extensions/concurrency.rb
|
421
419
|
- lib/good_job/adapter.rb
|
422
420
|
- lib/good_job/assignable_connection.rb
|
@@ -428,8 +426,7 @@ files:
|
|
428
426
|
- lib/good_job/daemon.rb
|
429
427
|
- lib/good_job/dependencies.rb
|
430
428
|
- lib/good_job/engine.rb
|
431
|
-
- lib/good_job/
|
432
|
-
- lib/good_job/filterable.rb
|
429
|
+
- lib/good_job/enqueuing.rb
|
433
430
|
- lib/good_job/job_performer.rb
|
434
431
|
- lib/good_job/log_subscriber.rb
|
435
432
|
- lib/good_job/multi_scheduler.rb
|
@@ -439,13 +436,6 @@ files:
|
|
439
436
|
- lib/good_job/probe_server.rb
|
440
437
|
- lib/good_job/scheduler.rb
|
441
438
|
- lib/good_job/version.rb
|
442
|
-
- lib/models/good_job/active_job_job.rb
|
443
|
-
- lib/models/good_job/base_record.rb
|
444
|
-
- lib/models/good_job/cron_entry.rb
|
445
|
-
- lib/models/good_job/execution.rb
|
446
|
-
- lib/models/good_job/job.rb
|
447
|
-
- lib/models/good_job/lockable.rb
|
448
|
-
- lib/models/good_job/process.rb
|
449
439
|
homepage: https://github.com/bensheldon/good_job
|
450
440
|
licenses:
|
451
441
|
- MIT
|