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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5dad621ffb6df8e754cc906eb748605d14525e7286f163f536c577d70f287c
|
4
|
+
data.tar.gz: 2f2973f6e21b7cf55ceb569cfff1bbf9fa1a579e544c7b96cae15c56cb890ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc0e6fe97519eabaee2f82f0de69cfbce24a928ba579ac57fd1b0c38b9693269a7b7bb69042d621a84fca224f2ec335bf9a5c2c7420a9e3e4cf9bbdf0f34460
|
7
|
+
data.tar.gz: b237d93f4741900bcc7263a754155328d31452cc040ee047d5bdca1dc0d0dbd9dfa416563dd70482d3d56f0bc73ef7d57b91a256760895a8ed9127cef2fb8127
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,66 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v3.3.2](https://github.com/bensheldon/good_job/tree/v3.3.2) (2022-07-27)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.3.1...v3.3.2)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Defer setting Adapter's execution mode until Rails initializes [\#683](https://github.com/bensheldon/good_job/pull/683) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
## [v3.3.1](https://github.com/bensheldon/good_job/tree/v3.3.1) (2022-07-26)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.3.0...v3.3.1)
|
14
|
+
|
15
|
+
**Implemented enhancements:**
|
16
|
+
|
17
|
+
- Show basename of proctitle [\#679](https://github.com/bensheldon/good_job/pull/679) ([bkeepers](https://github.com/bkeepers))
|
18
|
+
|
19
|
+
**Fixed bugs:**
|
20
|
+
|
21
|
+
- Only count \_active\_ processes in the Navbar [\#680](https://github.com/bensheldon/good_job/pull/680) ([bensheldon](https://github.com/bensheldon))
|
22
|
+
- Remove Zeitwerk and use explicit requires to be more like an engine [\#677](https://github.com/bensheldon/good_job/pull/677) ([bensheldon](https://github.com/bensheldon))
|
23
|
+
|
24
|
+
**Closed issues:**
|
25
|
+
|
26
|
+
- Dashboard UI Invalid count of running process [\#678](https://github.com/bensheldon/good_job/issues/678)
|
27
|
+
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- Lock to dotenv 2.7.x for Ruby 2.5 compatibility [\#682](https://github.com/bensheldon/good_job/pull/682) ([bensheldon](https://github.com/bensheldon))
|
31
|
+
- Create global GoodJob.configuration object [\#681](https://github.com/bensheldon/good_job/pull/681) ([bensheldon](https://github.com/bensheldon))
|
32
|
+
|
33
|
+
## [v3.3.0](https://github.com/bensheldon/good_job/tree/v3.3.0) (2022-07-24)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.2.0...v3.3.0)
|
36
|
+
|
37
|
+
**Implemented enhancements:**
|
38
|
+
|
39
|
+
- Dashboard: Update cron and processes to match jobs listing [\#676](https://github.com/bensheldon/good_job/pull/676) ([bkeepers](https://github.com/bkeepers))
|
40
|
+
- Dashboard: improvements to jobs index and show pages [\#672](https://github.com/bensheldon/good_job/pull/672) ([bkeepers](https://github.com/bkeepers))
|
41
|
+
|
42
|
+
**Fixed bugs:**
|
43
|
+
|
44
|
+
- Replace "timestamp" column-type in migrations with "datetime" [\#671](https://github.com/bensheldon/good_job/pull/671) ([bensheldon](https://github.com/bensheldon))
|
45
|
+
|
46
|
+
**Closed issues:**
|
47
|
+
|
48
|
+
- Calculating database connections [\#669](https://github.com/bensheldon/good_job/issues/669)
|
49
|
+
- Unable to Replace GoodJob's Logger [\#667](https://github.com/bensheldon/good_job/issues/667)
|
50
|
+
- Readme should consistently encourage usage of `config.good_job....` instead of `GoodJob.` configuration [\#628](https://github.com/bensheldon/good_job/issues/628)
|
51
|
+
- Improve the "Gem development" section of README? [\#551](https://github.com/bensheldon/good_job/issues/551)
|
52
|
+
- Simplify Rails initialization to only be a mountable Engine [\#543](https://github.com/bensheldon/good_job/issues/543)
|
53
|
+
|
54
|
+
**Merged pull requests:**
|
55
|
+
|
56
|
+
- Improve Readme description of v3 job preservation defaults [\#670](https://github.com/bensheldon/good_job/pull/670) ([bensheldon](https://github.com/bensheldon))
|
57
|
+
- update Gemfile.lock to latest dependencies [\#647](https://github.com/bensheldon/good_job/pull/647) ([jrochkind](https://github.com/jrochkind))
|
58
|
+
|
3
59
|
## [v3.2.0](https://github.com/bensheldon/good_job/tree/v3.2.0) (2022-07-12)
|
4
60
|
|
5
61
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.1.0...v3.2.0)
|
6
62
|
|
7
|
-
**
|
63
|
+
**Implemented enhancements:**
|
8
64
|
|
9
65
|
- Ordered queue handling by workers [\#665](https://github.com/bensheldon/good_job/pull/665) ([jrochkind](https://github.com/jrochkind))
|
10
66
|
|
@@ -14,7 +70,9 @@
|
|
14
70
|
|
15
71
|
**Implemented enhancements:**
|
16
72
|
|
73
|
+
- Show job/cron/process counts in the Navbar [\#663](https://github.com/bensheldon/good_job/pull/663) ([bensheldon](https://github.com/bensheldon))
|
17
74
|
- Improve Dashboard display of parameters \(CronEntry kwargs; Process configuration; Job and Execution database values\) [\#662](https://github.com/bensheldon/good_job/pull/662) ([bensheldon](https://github.com/bensheldon))
|
75
|
+
- Dequeing should be first-in first-out [\#651](https://github.com/bensheldon/good_job/pull/651) ([jrochkind](https://github.com/jrochkind))
|
18
76
|
|
19
77
|
**Fixed bugs:**
|
20
78
|
|
@@ -27,11 +85,6 @@
|
|
27
85
|
- Cron schedule page in dashboard not showing kwargs [\#608](https://github.com/bensheldon/good_job/issues/608)
|
28
86
|
- Paralelism x database connections [\#569](https://github.com/bensheldon/good_job/issues/569)
|
29
87
|
|
30
|
-
**Merged pull requests:**
|
31
|
-
|
32
|
-
- Show job/cron/process counts in the Navbar [\#663](https://github.com/bensheldon/good_job/pull/663) ([bensheldon](https://github.com/bensheldon))
|
33
|
-
- Dequeing should be first-in first-out [\#651](https://github.com/bensheldon/good_job/pull/651) ([jrochkind](https://github.com/jrochkind))
|
34
|
-
|
35
88
|
## [v3.0.2](https://github.com/bensheldon/good_job/tree/v3.0.2) (2022-07-10)
|
36
89
|
|
37
90
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.0.1...v3.0.2)
|
@@ -61,13 +114,16 @@
|
|
61
114
|
|
62
115
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.0.0...v3.0.1)
|
63
116
|
|
117
|
+
**Fixed bugs:**
|
118
|
+
|
119
|
+
- Fix `GoodJob.cleanup_preserved_jobs` to use `delete_all` instead of `destroy_all` [\#652](https://github.com/bensheldon/good_job/pull/652) ([bensheldon](https://github.com/bensheldon))
|
120
|
+
|
64
121
|
**Closed issues:**
|
65
122
|
|
66
123
|
- ERROR: relation "good\_jobs" does not exist at character 454 [\#308](https://github.com/bensheldon/good_job/issues/308)
|
67
124
|
|
68
125
|
**Merged pull requests:**
|
69
126
|
|
70
|
-
- Fix `GoodJob.cleanup_preserved_jobs` to use `delete_all` instead of `destroy_all` [\#652](https://github.com/bensheldon/good_job/pull/652) ([bensheldon](https://github.com/bensheldon))
|
71
127
|
- Create codeql-analysis.yml [\#648](https://github.com/bensheldon/good_job/pull/648) ([bensheldon](https://github.com/bensheldon))
|
72
128
|
|
73
129
|
## [v3.0.0](https://github.com/bensheldon/good_job/tree/v3.0.0) (2022-06-26)
|
@@ -1055,7 +1111,6 @@
|
|
1055
1111
|
- PgBouncer and prepared statements [\#269](https://github.com/bensheldon/good_job/issues/269)
|
1056
1112
|
- Question about locking internals [\#212](https://github.com/bensheldon/good_job/issues/212)
|
1057
1113
|
- Encoding::UndefinedConversionError \("\xE2" from ASCII-8BIT to UTF-8\) [\#198](https://github.com/bensheldon/good_job/issues/198)
|
1058
|
-
- tools for managing a 'fleet' of processes [\#150](https://github.com/bensheldon/good_job/issues/150)
|
1059
1114
|
|
1060
1115
|
**Merged pull requests:**
|
1061
1116
|
|
data/README.md
CHANGED
@@ -117,7 +117,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
117
117
|
YourJob.set(queue: :some_queue, wait: 5.minutes, priority: 10).perform_later
|
118
118
|
```
|
119
119
|
|
120
|
-
1. In development, GoodJob executes jobs immediately in a separate thread (async mode). In production, GoodJob provides different options:
|
120
|
+
1. In development, GoodJob executes jobs immediately in a separate thread ("async" mode). In production, GoodJob provides different options:
|
121
121
|
|
122
122
|
- By default, GoodJob separates job enqueuing from job execution so that jobs can be scaled independently of the web server. Use the GoodJob command-line tool to execute jobs:
|
123
123
|
|
@@ -199,7 +199,7 @@ Usage:
|
|
199
199
|
good_job cleanup_preserved_jobs
|
200
200
|
|
201
201
|
Options:
|
202
|
-
[--before-seconds-ago=SECONDS] # Destroy records finished more than this many seconds ago (env var: GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO, default:
|
202
|
+
[--before-seconds-ago=SECONDS] # Destroy records finished more than this many seconds ago (env var: GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO, default: 1209600 (14 days))
|
203
203
|
|
204
204
|
Destroys preserved job records.
|
205
205
|
|
@@ -226,6 +226,8 @@ GoodJob configuration can be placed within Rails `config` directory for all envi
|
|
226
226
|
Configuration examples:
|
227
227
|
|
228
228
|
```ruby
|
229
|
+
# config/initializers/good_job.rb OR config/application.rb OR config/environments/{RAILS_ENV}.rb
|
230
|
+
|
229
231
|
Rails.application.configure do
|
230
232
|
# Configure options individually...
|
231
233
|
config.good_job.preserve_job_records = true
|
@@ -275,9 +277,9 @@ Available configuration options are:
|
|
275
277
|
- `enable_cron` (boolean) whether to run cron process. Defaults to `false`. You can also set this with the environment variable `GOOD_JOB_ENABLE_CRON`.
|
276
278
|
- `cron` (hash) cron configuration. Defaults to `{}`. You can also set this as a JSON string with the environment variable `GOOD_JOB_CRON`
|
277
279
|
- `cleanup_discarded_jobs` (boolean) whether to destroy discarded jobs when cleaning up preserved jobs using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `true`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_DISCARDED_JOBS`. _This configuration is only used when {GoodJob.preserve_job_records} is `true`._
|
278
|
-
- `cleanup_preserved_jobs_before_seconds_ago` (integer) number of seconds to preserve jobs when using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `
|
279
|
-
- `cleanup_interval_jobs` (integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults to `
|
280
|
-
- `cleanup_interval_seconds` (integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults to `
|
280
|
+
- `cleanup_preserved_jobs_before_seconds_ago` (integer) number of seconds to preserve jobs when using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `1209600` (14 days). Can also be set with the environment variable `GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO`. _This configuration is only used when {GoodJob.preserve_job_records} is `true`._
|
281
|
+
- `cleanup_interval_jobs` (integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults to `1000`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_JOBS`.
|
282
|
+
- `cleanup_interval_seconds` (integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults to `600` (10 minutes). Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_SECONDS`.
|
281
283
|
- `inline_execution_respects_schedule` (boolean) Opt-in to future behavior of inline execution respecting scheduled jobs. Defaults to `false`.
|
282
284
|
- `logger` ([Rails Logger](https://api.rubyonrails.org/classes/ActiveSupport/Logger.html)) lets you set a custom logger for GoodJob. It should be an instance of a Rails `Logger` (Default: `Rails.logger`).
|
283
285
|
- `preserve_job_records` (boolean) keeps job records in your database even after jobs are completed. (Default: `true`)
|
@@ -310,21 +312,21 @@ config.good_job.execution_mode = :external
|
|
310
312
|
Good Job’s general behavior can also be configured via attributes directly on the `GoodJob` module:
|
311
313
|
|
312
314
|
- **`GoodJob.active_record_parent_class`** (string) The ActiveRecord parent class inherited by GoodJob's ActiveRecord model `GoodJob::Job` (defaults to `"ActiveRecord::Base"`). Configure this when using [multiple databases with ActiveRecord](https://guides.rubyonrails.org/active_record_multiple_databases.html) or when other custom configuration is necessary for the ActiveRecord model to connect to the Postgres database. _The value must be a String to avoid premature initialization of ActiveRecord._
|
313
|
-
- **`GoodJob.logger`** ([Rails Logger](https://api.rubyonrails.org/classes/ActiveSupport/Logger.html)) lets you set a custom logger for GoodJob. It should be an instance of a Rails `Logger`.
|
314
|
-
- **`GoodJob.preserve_job_records`** (boolean) keeps job records in your database even after jobs are completed. (Default: `true`)
|
315
|
-
- **`GoodJob.retry_on_unhandled_error`** (boolean) causes jobs to be re-queued and retried if they raise an instance of `StandardError`. Be advised this may lead to jobs being repeated infinitely ([see below for more on retries](#retries)). Instances of `Exception`, like SIGINT, will *always* be retried, regardless of this attribute’s value. (Default: `false`)
|
316
|
-
- **`GoodJob.on_thread_error`** (proc, lambda, or callable) will be called when an Exception. It can be useful for logging errors to bug tracking services, like Sentry or Airbrake.
|
317
315
|
|
318
316
|
You’ll generally want to configure these in `config/initializers/good_job.rb`, like so:
|
319
317
|
|
320
318
|
```ruby
|
321
319
|
# config/initializers/good_job.rb
|
322
320
|
GoodJob.active_record_parent_class = "ApplicationRecord"
|
323
|
-
GoodJob.preserve_job_records = true
|
324
|
-
GoodJob.retry_on_unhandled_error = false
|
325
|
-
GoodJob.on_thread_error = -> (exception) { Raven.capture_exception(exception) }
|
326
321
|
```
|
327
322
|
|
323
|
+
The following options are also configurable via accessors, but you are encouraged to use the configuration attributes instead because these may be deprecated and removed in the future:
|
324
|
+
|
325
|
+
- **`GoodJob.logger`** ([Rails Logger](https://api.rubyonrails.org/classes/ActiveSupport/Logger.html)) lets you set a custom logger for GoodJob. It should be an instance of a Rails `Logger`.
|
326
|
+
- **`GoodJob.preserve_job_records`** (boolean) keeps job records in your database even after jobs are completed. (Default: `true`)
|
327
|
+
- **`GoodJob.retry_on_unhandled_error`** (boolean) causes jobs to be re-queued and retried if they raise an instance of `StandardError`. Be advised this may lead to jobs being repeated infinitely ([see below for more on retries](#retries)). Instances of `Exception`, like SIGINT, will *always* be retried, regardless of this attribute’s value. (Default: `false`)
|
328
|
+
- **`GoodJob.on_thread_error`** (proc, lambda, or callable) will be called when an Exception. It can be useful for logging errors to bug tracking services, like Sentry or Airbrake.
|
329
|
+
|
328
330
|
### Dashboard
|
329
331
|
|
330
332
|
![Dashboard UI](https://github.com/bensheldon/good_job/raw/main/SCREENSHOT.png)
|
@@ -361,14 +363,7 @@ GoodJob includes a Dashboard as a mountable `Rails::Engine`.
|
|
361
363
|
end
|
362
364
|
```
|
363
365
|
|
364
|
-
|
365
|
-
|
366
|
-
```ruby
|
367
|
-
# eg in config/initializers/good_job.rb
|
368
|
-
GoodJob.preserve_job_records = true
|
369
|
-
```
|
370
|
-
|
371
|
-
See more at [Monitor and preserve worked jobs](#monitor-and-preserve-worked-jobs)
|
366
|
+
_To view finished (successful) and discarded (failed) jobs on the Dashboard, GoodJob must be configured to preserve job records. Preservation is enabled by default._
|
372
367
|
|
373
368
|
**Troubleshooting the Dashboard:** Some applications are unable to autoload the Goodjob Engine. To work around this, explicitly require the Engine at the top of your `config/application.rb` file, immediately after Rails is required and before Bundler requires the Rails' groups.
|
374
369
|
|
@@ -878,25 +873,24 @@ If your application is already using an ActiveJob backend, you will need to inst
|
|
878
873
|
|
879
874
|
GoodJob is fully instrumented with [`ActiveSupport::Notifications`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#introduction-to-instrumentation).
|
880
875
|
|
881
|
-
By default, GoodJob will preserve job records for 14 days after they are run, regardless of whether they succeed or
|
876
|
+
By default, GoodJob will preserve job records for 14 days after they are run, regardless of whether they succeed or raised an exception.
|
882
877
|
|
883
|
-
To
|
878
|
+
To instead delete job records immediately after they are finished:
|
884
879
|
|
885
880
|
```ruby
|
886
881
|
# config/initializers/good_job.rb
|
887
|
-
|
882
|
+
config.good_job.preserve_job_records = false # defaults to true; can also be `false` or `:on_unhandled_error`
|
888
883
|
```
|
889
884
|
|
890
|
-
GoodJob will automatically delete
|
885
|
+
GoodJob will automatically delete preserved job records after 14 days. The retention period, as well as the frequency GoodJob checks for deletable records can be configured:
|
891
886
|
|
892
887
|
```ruby
|
893
|
-
|
894
|
-
config.
|
895
|
-
config.
|
896
|
-
config.cleanup_interval_seconds = 10.minutes.to_i # Number of seconds between deletion sweeps.
|
888
|
+
config.good_job.cleanup_preserved_jobs_before_seconds_ago = 14.days.to_i
|
889
|
+
config.good_job.cleanup_interval_jobs = 1_000 # Number of executed jobs between deletion sweeps.
|
890
|
+
config.good_job.cleanup_interval_seconds = 10.minutes.to_i # Number of seconds between deletion sweeps.
|
897
891
|
```
|
898
892
|
|
899
|
-
It is also possible to manually trigger a cleanup:
|
893
|
+
It is also possible to manually trigger a cleanup of preserved job records:
|
900
894
|
|
901
895
|
- For example, in a Rake task:
|
902
896
|
|
@@ -1041,7 +1035,7 @@ For gem development and debugging information, please review the [README's Gem D
|
|
1041
1035
|
# Clone the repository locally
|
1042
1036
|
git clone git@github.com:bensheldon/good_job.git
|
1043
1037
|
|
1044
|
-
# Set up the
|
1038
|
+
# Set up the gem development environment
|
1045
1039
|
bin/setup
|
1046
1040
|
```
|
1047
1041
|
|
@@ -1080,6 +1074,10 @@ bundle install
|
|
1080
1074
|
Tests can be run against the primary development environment:
|
1081
1075
|
|
1082
1076
|
```bash
|
1077
|
+
# Set up the gem development environment
|
1078
|
+
bin/setup
|
1079
|
+
|
1080
|
+
# Run the tests
|
1083
1081
|
bin/rspec
|
1084
1082
|
```
|
1085
1083
|
|
@@ -4,11 +4,13 @@ import renderCharts from "charts";
|
|
4
4
|
import checkboxToggle from "checkbox_toggle";
|
5
5
|
import documentReady from "document_ready";
|
6
6
|
import showToasts from "toasts";
|
7
|
+
import setupPopovers from "popovers";
|
7
8
|
import LivePoll from "live_poll";
|
8
9
|
|
9
10
|
documentReady(function() {
|
10
11
|
renderCharts();
|
11
12
|
showToasts();
|
13
|
+
setupPopovers();
|
12
14
|
checkboxToggle();
|
13
15
|
|
14
16
|
const livePoll = new LivePoll
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export default function() {
|
2
|
+
document.querySelectorAll('[data-bs-toggle="popover"]').forEach((el) => {
|
3
|
+
new bootstrap.Popover(el, {
|
4
|
+
template: '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><pre class="popover-body text-wrap text-break"></pre></div>'
|
5
|
+
})
|
6
|
+
})
|
7
|
+
}
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GoodJob
|
3
|
+
module Reportable
|
4
|
+
# There are 3 buckets of non-overlapping statuses:
|
5
|
+
# 1. The job will be executed
|
6
|
+
# - queued: The job will execute immediately when an execution thread becomes available.
|
7
|
+
# - scheduled: The job is scheduled to execute in the future.
|
8
|
+
# - retried: The job previously errored on execution and will be re-executed in the future.
|
9
|
+
# 2. The job is being executed
|
10
|
+
# - running: the job is actively being executed by an execution thread
|
11
|
+
# 3. The job will not execute
|
12
|
+
# - finished: The job executed successfully
|
13
|
+
# - discarded: The job previously errored on execution and will not be re-executed in the future.
|
14
|
+
#
|
15
|
+
# @return [Symbol]
|
16
|
+
def status
|
17
|
+
if finished_at.present?
|
18
|
+
if error.present? && retried_good_job_id.present?
|
19
|
+
:retried
|
20
|
+
elsif error.present? && retried_good_job_id.nil?
|
21
|
+
:discarded
|
22
|
+
else
|
23
|
+
:finished
|
24
|
+
end
|
25
|
+
elsif (scheduled_at || created_at) > DateTime.current
|
26
|
+
if serialized_params.fetch('executions', 0) > 1
|
27
|
+
:retried
|
28
|
+
else
|
29
|
+
:scheduled
|
30
|
+
end
|
31
|
+
elsif running?
|
32
|
+
:running
|
33
|
+
else
|
34
|
+
:queued
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# The last relevant timestamp for this execution
|
39
|
+
def last_status_at
|
40
|
+
finished_at || performed_at || scheduled_at || created_at
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
File without changes
|
File without changes
|
@@ -4,6 +4,7 @@ module GoodJob
|
|
4
4
|
class Execution < BaseRecord
|
5
5
|
include Lockable
|
6
6
|
include Filterable
|
7
|
+
include Reportable
|
7
8
|
|
8
9
|
# Raised if something attempts to execute a previously completed Execution again.
|
9
10
|
PreviouslyPerformedError = Class.new(StandardError)
|
@@ -312,40 +313,6 @@ module GoodJob
|
|
312
313
|
end
|
313
314
|
end
|
314
315
|
|
315
|
-
# There are 3 buckets of non-overlapping statuses:
|
316
|
-
# 1. The job will be executed
|
317
|
-
# - queued: The job will execute immediately when an execution thread becomes available.
|
318
|
-
# - scheduled: The job is scheduled to execute in the future.
|
319
|
-
# - retried: The job previously errored on execution and will be re-executed in the future.
|
320
|
-
# 2. The job is being executed
|
321
|
-
# - running: the job is actively being executed by an execution thread
|
322
|
-
# 3. The job will not execute
|
323
|
-
# - finished: The job executed successfully
|
324
|
-
# - discarded: The job previously errored on execution and will not be re-executed in the future.
|
325
|
-
#
|
326
|
-
# @return [Symbol]
|
327
|
-
def status
|
328
|
-
if finished_at.present?
|
329
|
-
if error.present? && retried_good_job_id.present?
|
330
|
-
:retried
|
331
|
-
elsif error.present? && retried_good_job_id.nil?
|
332
|
-
:discarded
|
333
|
-
else
|
334
|
-
:finished
|
335
|
-
end
|
336
|
-
elsif (scheduled_at || created_at) > DateTime.current
|
337
|
-
if serialized_params.fetch('executions', 0) > 1
|
338
|
-
:retried
|
339
|
-
else
|
340
|
-
:scheduled
|
341
|
-
end
|
342
|
-
elsif running?
|
343
|
-
:running
|
344
|
-
else
|
345
|
-
:queued
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
316
|
# Return formatted serialized_params for display in the dashboard
|
350
317
|
# @return [Hash]
|
351
318
|
def display_serialized_params
|
@@ -366,11 +333,6 @@ module GoodJob
|
|
366
333
|
serialized_params.fetch('executions', 0) + 1
|
367
334
|
end
|
368
335
|
|
369
|
-
# The last relevant timestamp for this execution
|
370
|
-
def last_status_at
|
371
|
-
finished_at || performed_at || scheduled_at || created_at
|
372
|
-
end
|
373
|
-
|
374
336
|
# Time between when this job was expected to run and when it started running
|
375
337
|
def queue_latency
|
376
338
|
now = Time.zone.now
|
File without changes
|
@@ -8,6 +8,7 @@ module GoodJob
|
|
8
8
|
class Job < BaseRecord
|
9
9
|
include Filterable
|
10
10
|
include Lockable
|
11
|
+
include Reportable
|
11
12
|
|
12
13
|
# Raised when an inappropriate action is applied to a Job based on its state.
|
13
14
|
ActionForStateMismatchError = Class.new(StandardError)
|
@@ -27,7 +28,7 @@ module GoodJob
|
|
27
28
|
self.primary_key = 'active_job_id'
|
28
29
|
self.advisory_lockable_column = 'active_job_id'
|
29
30
|
|
30
|
-
has_many :executions, -> { order(created_at: :asc) }, class_name: 'GoodJob::Execution', foreign_key: 'active_job_id', inverse_of: :job
|
31
|
+
has_many :executions, -> { order(created_at: :asc) }, class_name: 'GoodJob::Execution', foreign_key: 'active_job_id', inverse_of: :job # rubocop:disable Rails/HasManyOrHasOneDependent
|
31
32
|
|
32
33
|
# Only the most-recent unretried execution represents a "Job"
|
33
34
|
default_scope { where(retried_good_job_id: nil) }
|
@@ -73,32 +74,6 @@ module GoodJob
|
|
73
74
|
serialized_params['job_class']
|
74
75
|
end
|
75
76
|
|
76
|
-
def last_status_at
|
77
|
-
finished_at || performed_at || scheduled_at || created_at
|
78
|
-
end
|
79
|
-
|
80
|
-
def status
|
81
|
-
if finished_at.present?
|
82
|
-
if error.present? && retried_good_job_id.present?
|
83
|
-
:retried
|
84
|
-
elsif error.present? && retried_good_job_id.nil?
|
85
|
-
:discarded
|
86
|
-
else
|
87
|
-
:finished
|
88
|
-
end
|
89
|
-
elsif (scheduled_at || created_at) > DateTime.current
|
90
|
-
if serialized_params.fetch('executions', 0) > 1
|
91
|
-
:retried
|
92
|
-
else
|
93
|
-
:scheduled
|
94
|
-
end
|
95
|
-
elsif running?
|
96
|
-
:running
|
97
|
-
else
|
98
|
-
:queued
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
77
|
# Override #reload to add a custom scope to ensure the reloaded record is the head execution
|
103
78
|
# @return [Job]
|
104
79
|
def reload(options = nil)
|
File without changes
|
@@ -1,61 +1,64 @@
|
|
1
|
-
<div class="
|
2
|
-
<h2>Cron Schedules</h2>
|
1
|
+
<div class="bg-light break-out border-bottom">
|
2
|
+
<h2 class="container-fluid pt-3 pb-2">Cron Schedules</h2>
|
3
3
|
</div>
|
4
4
|
|
5
|
-
|
6
|
-
<div class="
|
7
|
-
<
|
8
|
-
<
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<th>Next scheduled</th>
|
21
|
-
<th>Last run</th>
|
22
|
-
<th>Actions</th>
|
23
|
-
</thead>
|
24
|
-
<tbody>
|
25
|
-
<% @cron_entries.each do |cron_entry| %>
|
26
|
-
<tr id="<%= dom_id(cron_entry) %>">
|
27
|
-
<td class="font-monospace"><%= cron_entry.key %></td>
|
28
|
-
<td class="font-monospace"><%= cron_entry.schedule %></td>
|
29
|
-
<td>
|
30
|
-
<%= tag.button("Inspect", type: "button", class: "btn btn-sm btn-outline-primary", role: "button",
|
31
|
-
data: { bs_toggle: "collapse", bs_target: "##{dom_id(cron_entry, 'properties')}" },
|
32
|
-
aria: { expanded: false, controls: dom_id(cron_entry, 'properties') }) %>
|
33
|
-
<%= tag.pre(JSON.pretty_generate(cron_entry.display_properties), id: dom_id(cron_entry, 'properties'), class: "collapse cron-entry-properties") %>
|
34
|
-
</td>
|
35
|
-
<td><%= cron_entry.description %></td>
|
36
|
-
<td><%= cron_entry.next_at %></td>
|
37
|
-
<td>
|
38
|
-
<% if cron_entry.last_job.present? %>
|
39
|
-
<%= link_to cron_entry.last_at, cron_entry_path(cron_entry), title: "Job #{cron_entry.last_job.id}" %>
|
40
|
-
<% end %>
|
41
|
-
</td>
|
42
|
-
<td>
|
43
|
-
<%= button_to enqueue_cron_entry_path(cron_entry.id), method: :post, class: "btn btn-sm btn-outline-primary", form_class: "d-inline-block", aria: { label: "Run cron entry now" }, title: "Run cron entry now", data: { confirm: "Confirm run cron entry now" } do %>
|
44
|
-
<%= render "good_job/shared/icons/play" %>
|
45
|
-
<% end %>
|
46
|
-
</td>
|
47
|
-
</tr>
|
5
|
+
<div class="card my-3">
|
6
|
+
<div class="list-group list-group-flush text-nowrap" role="table">
|
7
|
+
<header class="list-group-item bg-light">
|
8
|
+
<div class="row small text-muted text-uppercase align-items-center">
|
9
|
+
<div class="col"></div>
|
10
|
+
<div class="col">Class</div>
|
11
|
+
<div class="col">Schedule</div>
|
12
|
+
<div class="col">Next scheduled</div>
|
13
|
+
<div class="col">Last run</div>
|
14
|
+
<div class="col text-end">
|
15
|
+
<%= tag.button type: "button", class: "btn btn-sm text-muted", role: "button",
|
16
|
+
data: { bs_toggle: "collapse", bs_target: ".cron-entry-properties" },
|
17
|
+
aria: { expanded: false, controls: @cron_entries.map { |cron_entry| "##{dom_id(cron_entry, 'properties')}" }.join(" ") } do %>
|
18
|
+
<%= render_icon "info" %>
|
19
|
+
<span class="visually-hidden">Inspect</span>
|
48
20
|
<% end %>
|
49
|
-
</
|
50
|
-
</
|
51
|
-
</
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</header>
|
24
|
+
<% @cron_entries.each do |cron_entry| %>
|
25
|
+
<div id="<%= dom_id(cron_entry) %>" class="list-group-item py-3" role="row">
|
26
|
+
<div class="row align-items-center">
|
27
|
+
<div class="col">
|
28
|
+
<div class="small font-monospace"><%= cron_entry.key %></div>
|
29
|
+
<div class="small text-muted"><%= cron_entry.description %></div>
|
30
|
+
</div>
|
31
|
+
<div class="col"><%= tag.span tag.code(cron_entry.job_class), class: "fs-5 mb-0" %></div>
|
32
|
+
<div class="col font-monospace fw-bold"><%= cron_entry.schedule %></div>
|
33
|
+
<div class="col small"><%= relative_time cron_entry.next_at %></div>
|
34
|
+
<div class="col small">
|
35
|
+
<% if cron_entry.last_job.present? %>
|
36
|
+
<%= link_to relative_time(cron_entry.last_at), cron_entry_path(cron_entry), title: "Job #{cron_entry.last_job.id}" %>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
39
|
+
<div class="col d-flex gap-3 justify-content-end">
|
40
|
+
<%= button_to enqueue_cron_entry_path(cron_entry.id), method: :post, class: "btn btn-sm btn-outline-primary", form_class: "d-inline-block", aria: { label: "Run cron entry now" }, title: "Run cron entry now", data: { confirm: "Confirm run cron entry now" } do %>
|
41
|
+
<%= render "good_job/shared/icons/play" %>
|
42
|
+
Run Now
|
43
|
+
<% end %>
|
44
|
+
<%= tag.button type: "button", class: "btn btn-sm text-muted", role: "button",
|
45
|
+
title: "Inspect",
|
46
|
+
data: { bs_toggle: "collapse", bs_target: "##{dom_id(cron_entry, 'properties')}" },
|
47
|
+
aria: { expanded: false, controls: dom_id(cron_entry, "properties") } do %>
|
48
|
+
<%= render_icon "info" %>
|
49
|
+
<span class="visually-hidden">Inspect</span>
|
50
|
+
<% end %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
<%= tag.div id: dom_id(cron_entry, 'properties'), class: "collapse cron-entry-properties list-group-item collapse small bg-dark text-light" do %>
|
55
|
+
<%= tag.pre JSON.pretty_generate(cron_entry.display_properties) %>
|
56
|
+
<% end %>
|
57
|
+
<% end %>
|
58
|
+
<% if @cron_entries.empty? %>
|
59
|
+
<div class="list-group-item py-4 text-center text-muted">
|
60
|
+
No cron schedules found.
|
61
|
+
</div>
|
62
|
+
<% end %>
|
52
63
|
</div>
|
53
|
-
|
54
|
-
<div class="card my-3">
|
55
|
-
<div class="card-body">
|
56
|
-
<p class="card-text">
|
57
|
-
<em>No cron schedules found.</em>
|
58
|
-
</p>
|
59
|
-
</div>
|
60
|
-
</div>
|
61
|
-
<% end %>
|
64
|
+
</div>
|