good_job 1.8.0 → 1.9.4
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 +4 -4
- data/CHANGELOG.md +111 -11
- data/README.md +15 -12
- data/engine/app/controllers/good_job/dashboards_controller.rb +7 -5
- data/engine/app/views/shared/_chart.erb +3 -2
- data/exe/good_job +3 -2
- data/lib/active_job/queue_adapters/good_job_adapter.rb +0 -4
- data/lib/good_job.rb +26 -8
- data/lib/good_job/adapter.rb +35 -17
- data/lib/good_job/cli.rb +17 -5
- data/lib/good_job/configuration.rb +26 -34
- data/lib/good_job/current_execution.rb +0 -1
- data/lib/good_job/daemon.rb +6 -0
- data/lib/good_job/execution_result.rb +20 -0
- data/lib/good_job/job.rb +47 -37
- data/lib/good_job/job_performer.rb +2 -2
- data/lib/good_job/lockable.rb +4 -7
- data/lib/good_job/log_subscriber.rb +15 -14
- data/lib/good_job/multi_scheduler.rb +10 -1
- data/lib/good_job/notifier.rb +7 -6
- data/lib/good_job/poller.rb +10 -6
- data/lib/good_job/scheduler.rb +55 -20
- data/lib/good_job/version.rb +1 -1
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '039fb246e970dd21bfa88b72a50fd96038c00bd4dd0c323966936a9899ade684'
|
4
|
+
data.tar.gz: bb19f26989f503ce572759c7726b07ee56208b0defc793de6e0ca07c500cb869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78516e648a709192486d728061d19850f108daa6863ec714b51ee1eb0e03c1ca7a6294d4736e70e8d657d34abfd8105168a94b26a2fe7ec33df0db4e04587574
|
7
|
+
data.tar.gz: 416b0b8fb14e082abefffd7d5a4ee7eea53725eeba4dd0d7786e6c8caaa833cb318a5205863ae6aa6e3d475e9abfd3aff687ccde2bc93b4b435764f614c8251a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,103 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [v1.
|
3
|
+
## [v1.9.4](https://github.com/bensheldon/good_job/tree/v1.9.4) (2021-05-18)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.9.3...v1.9.4)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Add "running" jobs state to Dashboard [\#253](https://github.com/bensheldon/good_job/pull/253) ([morgoth](https://github.com/morgoth))
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- Unify displaying timestamps [\#252](https://github.com/bensheldon/good_job/pull/252) ([morgoth](https://github.com/morgoth))
|
14
|
+
- Fix dashboard jobs endless pagination with timezone handling [\#251](https://github.com/bensheldon/good_job/pull/251) ([morgoth](https://github.com/morgoth))
|
15
|
+
|
16
|
+
**Closed issues:**
|
17
|
+
|
18
|
+
- exception\_executions not counted correctly? [\#215](https://github.com/bensheldon/good_job/issues/215)
|
19
|
+
- Document issues with PgBouncer and session-level Advisory Locks [\#52](https://github.com/bensheldon/good_job/issues/52)
|
20
|
+
|
21
|
+
**Merged pull requests:**
|
22
|
+
|
23
|
+
- Add handy scope for filtering by job class [\#259](https://github.com/bensheldon/good_job/pull/259) ([morgoth](https://github.com/morgoth))
|
24
|
+
- Nest exception stub within job class and cleanup let! precedence to fix flakey JRuby tests [\#254](https://github.com/bensheldon/good_job/pull/254) ([bensheldon](https://github.com/bensheldon))
|
25
|
+
- Move good\_job\_spec.rb to proper location in lib directory [\#250](https://github.com/bensheldon/good_job/pull/250) ([bensheldon](https://github.com/bensheldon))
|
26
|
+
- Refactor deprecated wait parameter and assorted improvements [\#249](https://github.com/bensheldon/good_job/pull/249) ([bensheldon](https://github.com/bensheldon))
|
27
|
+
- Update development dependencies \(Rails v6.1.3.2\) [\#248](https://github.com/bensheldon/good_job/pull/248) ([bensheldon](https://github.com/bensheldon))
|
28
|
+
- Update YARD documentation param types and return values [\#239](https://github.com/bensheldon/good_job/pull/239) ([bensheldon](https://github.com/bensheldon))
|
29
|
+
|
30
|
+
## [v1.9.3](https://github.com/bensheldon/good_job/tree/v1.9.3) (2021-05-10)
|
31
|
+
|
32
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.9.2...v1.9.3)
|
33
|
+
|
34
|
+
**Implemented enhancements:**
|
35
|
+
|
36
|
+
- Add async\_server detection for extensions of rack handler [\#246](https://github.com/bensheldon/good_job/pull/246) ([bensheldon](https://github.com/bensheldon))
|
37
|
+
|
38
|
+
**Closed issues:**
|
39
|
+
|
40
|
+
- Not processing unfinished jobs across server restarts using async\_server mode on Iodine server [\#244](https://github.com/bensheldon/good_job/issues/244)
|
41
|
+
- No connection pool for 'ActiveRecord::Base' found [\#236](https://github.com/bensheldon/good_job/issues/236)
|
42
|
+
|
43
|
+
## [v1.9.2](https://github.com/bensheldon/good_job/tree/v1.9.2) (2021-05-10)
|
44
|
+
|
45
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.9.1...v1.9.2)
|
46
|
+
|
47
|
+
**Fixed bugs:**
|
48
|
+
|
49
|
+
- Run Scheduler\#warm\_cache operation in threadpool executor [\#242](https://github.com/bensheldon/good_job/pull/242) ([bensheldon](https://github.com/bensheldon))
|
50
|
+
|
51
|
+
**Closed issues:**
|
52
|
+
|
53
|
+
- Jobs not visible in dashboard [\#245](https://github.com/bensheldon/good_job/issues/245)
|
54
|
+
|
55
|
+
**Merged pull requests:**
|
56
|
+
|
57
|
+
- Use GoodJob::Job::ExecutionResult object instead of job execution returning an ordered array [\#241](https://github.com/bensheldon/good_job/pull/241) ([bensheldon](https://github.com/bensheldon))
|
58
|
+
- Update development dependencies [\#240](https://github.com/bensheldon/good_job/pull/240) ([bensheldon](https://github.com/bensheldon))
|
59
|
+
|
60
|
+
## [v1.9.1](https://github.com/bensheldon/good_job/tree/v1.9.1) (2021-04-19)
|
61
|
+
|
62
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.9.0...v1.9.1)
|
63
|
+
|
64
|
+
**Implemented enhancements:**
|
65
|
+
|
66
|
+
- Allow to specify parent class for active record [\#238](https://github.com/bensheldon/good_job/pull/238) ([morgoth](https://github.com/morgoth))
|
67
|
+
|
68
|
+
## [v1.9.0](https://github.com/bensheldon/good_job/tree/v1.9.0) (2021-04-16)
|
69
|
+
|
70
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.8.0...v1.9.0)
|
71
|
+
|
72
|
+
**Implemented enhancements:**
|
73
|
+
|
74
|
+
- Add `async_server` option to run async only in Rails web server process [\#230](https://github.com/bensheldon/good_job/pull/230) ([bensheldon](https://github.com/bensheldon))
|
75
|
+
- FreeBSD startup script [\#221](https://github.com/bensheldon/good_job/pull/221) ([lauer](https://github.com/lauer))
|
76
|
+
|
77
|
+
**Fixed bugs:**
|
78
|
+
|
79
|
+
- Fix instrumentation of GoodJob::Poller finished\_timer\_task event [\#233](https://github.com/bensheldon/good_job/pull/233) ([bensheldon](https://github.com/bensheldon))
|
80
|
+
|
81
|
+
**Closed issues:**
|
82
|
+
|
83
|
+
- Cannot run db:migrate when execution mode is :async [\#229](https://github.com/bensheldon/good_job/issues/229)
|
84
|
+
- How do you enqueue a job to be executed immediately outside of Rails \(eg. creating a new record of good\_jobs in Postgresql\)? [\#225](https://github.com/bensheldon/good_job/issues/225)
|
85
|
+
- Feature Ideas [\#220](https://github.com/bensheldon/good_job/issues/220)
|
86
|
+
- Goodjob startup script for FreeBSD [\#214](https://github.com/bensheldon/good_job/issues/214)
|
87
|
+
- Only start async mode executors when server is running [\#194](https://github.com/bensheldon/good_job/issues/194)
|
88
|
+
|
89
|
+
**Merged pull requests:**
|
90
|
+
|
91
|
+
- Move executable flags from constants to accessors on GoodJob::CLI [\#234](https://github.com/bensheldon/good_job/pull/234) ([bensheldon](https://github.com/bensheldon))
|
92
|
+
- Add custom Scheduler::TimerSet [\#232](https://github.com/bensheldon/good_job/pull/232) ([bensheldon](https://github.com/bensheldon))
|
93
|
+
- Fix assorted constant references in YARD documentation [\#231](https://github.com/bensheldon/good_job/pull/231) ([bensheldon](https://github.com/bensheldon))
|
94
|
+
- Update GH Test Matrix with latest JRuby 9.2.17.0 [\#228](https://github.com/bensheldon/good_job/pull/228) ([tedhexaflow](https://github.com/tedhexaflow))
|
95
|
+
- Update gem dependencies [\#227](https://github.com/bensheldon/good_job/pull/227) ([bensheldon](https://github.com/bensheldon))
|
96
|
+
- Remove leftover text from Readme [\#226](https://github.com/bensheldon/good_job/pull/226) ([weh](https://github.com/weh))
|
97
|
+
- Fix appraisal and bundler version CI conflicts [\#224](https://github.com/bensheldon/good_job/pull/224) ([bensheldon](https://github.com/bensheldon))
|
98
|
+
- Update GH Test Matrix with latest JRuby [\#223](https://github.com/bensheldon/good_job/pull/223) ([tedhexaflow](https://github.com/tedhexaflow))
|
99
|
+
|
100
|
+
## [v1.8.0](https://github.com/bensheldon/good_job/tree/v1.8.0) (2021-03-04)
|
4
101
|
|
5
102
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v1.7.1...v1.8.0)
|
6
103
|
|
@@ -57,7 +154,7 @@
|
|
57
154
|
|
58
155
|
**Closed issues:**
|
59
156
|
|
60
|
-
- Rails 6.1 & async - `
|
157
|
+
- Rails 6.1 & async - `queue_parser': undefined method `first' for "\*":String \(NoMethodError\) [\#195](https://github.com/bensheldon/good_job/issues/195)
|
61
158
|
|
62
159
|
**Merged pull requests:**
|
63
160
|
|
@@ -99,7 +196,6 @@
|
|
99
196
|
**Merged pull requests:**
|
100
197
|
|
101
198
|
- Add missing YARD docs and Dashboard screenshot [\#191](https://github.com/bensheldon/good_job/pull/191) ([bensheldon](https://github.com/bensheldon))
|
102
|
-
- Update all Lockable queries to use exec\_query instead of execute; clear async\_exec results [\#189](https://github.com/bensheldon/good_job/pull/189) ([bensheldon](https://github.com/bensheldon))
|
103
199
|
|
104
200
|
## [v1.4.0](https://github.com/bensheldon/good_job/tree/v1.4.0) (2020-12-31)
|
105
201
|
|
@@ -126,6 +222,7 @@
|
|
126
222
|
**Merged pull requests:**
|
127
223
|
|
128
224
|
- Run tests with Rails default configuration to enable Zeitwerk [\#190](https://github.com/bensheldon/good_job/pull/190) ([bensheldon](https://github.com/bensheldon))
|
225
|
+
- Update all Lockable queries to use exec\_query instead of execute; clear async\_exec results [\#189](https://github.com/bensheldon/good_job/pull/189) ([bensheldon](https://github.com/bensheldon))
|
129
226
|
- Have Lockable\#advisory\_locked? directly query pg\_locks table [\#188](https://github.com/bensheldon/good_job/pull/188) ([bensheldon](https://github.com/bensheldon))
|
130
227
|
- Update development gems, including Rails v6.1 and Rails HEAD [\#186](https://github.com/bensheldon/good_job/pull/186) ([bensheldon](https://github.com/bensheldon))
|
131
228
|
- Update Appraisals for Rails 6.1 [\#183](https://github.com/bensheldon/good_job/pull/183) ([bensheldon](https://github.com/bensheldon))
|
@@ -217,7 +314,7 @@
|
|
217
314
|
**Implemented enhancements:**
|
218
315
|
|
219
316
|
- Preserve only failed jobs [\#136](https://github.com/bensheldon/good_job/issues/136)
|
220
|
-
- Add `GoodJob.
|
317
|
+
- Add `GoodJob.preserve_job_records = :on_unhandled_error` option to only preserve jobs that errored [\#145](https://github.com/bensheldon/good_job/pull/145) ([morgoth](https://github.com/morgoth))
|
221
318
|
|
222
319
|
**Fixed bugs:**
|
223
320
|
|
@@ -250,7 +347,7 @@
|
|
250
347
|
- Update Gemspec to reflect that GoodJob is not compatible with Rails 5.1 [\#143](https://github.com/bensheldon/good_job/pull/143) ([bensheldon](https://github.com/bensheldon))
|
251
348
|
- Prevent jobs hanging [\#141](https://github.com/bensheldon/good_job/pull/141) ([morgoth](https://github.com/morgoth))
|
252
349
|
- Add explicit require\_paths to gemspec for engine [\#134](https://github.com/bensheldon/good_job/pull/134) ([bensheldon](https://github.com/bensheldon))
|
253
|
-
- Use `connection.
|
350
|
+
- Use `connection.quote_table_name` and add spacing for SQL concatenation [\#124](https://github.com/bensheldon/good_job/pull/124) ([bensheldon](https://github.com/bensheldon))
|
254
351
|
|
255
352
|
**Closed issues:**
|
256
353
|
|
@@ -276,7 +373,7 @@
|
|
276
373
|
|
277
374
|
**Implemented enhancements:**
|
278
375
|
|
279
|
-
- Add environment variable to mirror `
|
376
|
+
- Add environment variable to mirror `cleanup_preserved_jobs --before-seconds-ago=SECONDS` [\#110](https://github.com/bensheldon/good_job/issues/110)
|
280
377
|
- Allow env variable config for cleanups [\#114](https://github.com/bensheldon/good_job/pull/114) ([gadimbaylisahil](https://github.com/gadimbaylisahil))
|
281
378
|
|
282
379
|
**Fixed bugs:**
|
@@ -296,6 +393,7 @@
|
|
296
393
|
- Have YARD render markdown files with GFM \(Github Flavored Markdown\) [\#113](https://github.com/bensheldon/good_job/pull/113) ([bensheldon](https://github.com/bensheldon))
|
297
394
|
- Add markdownlint to lint readme [\#109](https://github.com/bensheldon/good_job/pull/109) ([bensheldon](https://github.com/bensheldon))
|
298
395
|
- Remove unused method in PgLocks [\#107](https://github.com/bensheldon/good_job/pull/107) ([gadimbaylisahil](https://github.com/gadimbaylisahil))
|
396
|
+
- Re-organize Readme: frontload configuration, add Table of Contents [\#106](https://github.com/bensheldon/good_job/pull/106) ([bensheldon](https://github.com/bensheldon))
|
299
397
|
|
300
398
|
## [v1.2.3](https://github.com/bensheldon/good_job/tree/v1.2.3) (2020-08-27)
|
301
399
|
|
@@ -326,16 +424,15 @@
|
|
326
424
|
|
327
425
|
**Closed issues:**
|
328
426
|
|
329
|
-
- Add test for `rails g
|
427
|
+
- Add test for `rails g good_job:install` [\#57](https://github.com/bensheldon/good_job/issues/57)
|
330
428
|
|
331
429
|
**Merged pull requests:**
|
332
430
|
|
333
|
-
- Re-organize Readme: frontload configuration, add Table of Contents [\#106](https://github.com/bensheldon/good_job/pull/106) ([bensheldon](https://github.com/bensheldon))
|
334
431
|
- Use more ActiveRecord in Lockable and not connection.execute [\#102](https://github.com/bensheldon/good_job/pull/102) ([bensheldon](https://github.com/bensheldon))
|
335
432
|
- Run CI tests on Ruby 2.5, 2.6, and 2.7 [\#101](https://github.com/bensheldon/good_job/pull/101) ([arku](https://github.com/arku))
|
336
433
|
- Fix Ruby 2.7 keyword arguments warning [\#98](https://github.com/bensheldon/good_job/pull/98) ([arku](https://github.com/arku))
|
337
434
|
- Remove executor/reloader for less interlocking [\#97](https://github.com/bensheldon/good_job/pull/97) ([sj26](https://github.com/sj26))
|
338
|
-
- Add test for `rails g
|
435
|
+
- Add test for `rails g good_job:install` [\#94](https://github.com/bensheldon/good_job/pull/94) ([arku](https://github.com/arku))
|
339
436
|
|
340
437
|
## [v1.2.1](https://github.com/bensheldon/good_job/tree/v1.2.1) (2020-08-21)
|
341
438
|
|
@@ -463,7 +560,6 @@
|
|
463
560
|
|
464
561
|
- Add migration generator [\#56](https://github.com/bensheldon/good_job/pull/56) ([thedanbob](https://github.com/thedanbob))
|
465
562
|
- Fix migration script in readme [\#55](https://github.com/bensheldon/good_job/pull/55) ([thedanbob](https://github.com/thedanbob))
|
466
|
-
- Move where\(scheduled\_at: Time.current\) into dynamic part of GoodJob::Job::Performer [\#42](https://github.com/bensheldon/good_job/pull/42) ([bensheldon](https://github.com/bensheldon))
|
467
563
|
|
468
564
|
## [v1.0.1](https://github.com/bensheldon/good_job/tree/v1.0.1) (2020-07-22)
|
469
565
|
|
@@ -502,6 +598,10 @@
|
|
502
598
|
|
503
599
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v0.8.0...v0.8.1)
|
504
600
|
|
601
|
+
**Merged pull requests:**
|
602
|
+
|
603
|
+
- Move where\(scheduled\_at: Time.current\) into dynamic part of GoodJob::Job::Performer [\#42](https://github.com/bensheldon/good_job/pull/42) ([bensheldon](https://github.com/bensheldon))
|
604
|
+
|
505
605
|
## [v0.8.0](https://github.com/bensheldon/good_job/tree/v0.8.0) (2020-07-17)
|
506
606
|
|
507
607
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v0.7.0...v0.8.0)
|
@@ -539,7 +639,7 @@
|
|
539
639
|
- Update Github Action Workflow for Backlog Project Board [\#35](https://github.com/bensheldon/good_job/pull/35) ([bensheldon](https://github.com/bensheldon))
|
540
640
|
- Add configuration options to good\_job executable [\#33](https://github.com/bensheldon/good_job/pull/33) ([bensheldon](https://github.com/bensheldon))
|
541
641
|
- Extract Job querying behavior out of Scheduler [\#31](https://github.com/bensheldon/good_job/pull/31) ([bensheldon](https://github.com/bensheldon))
|
542
|
-
- Allow configuration of Rails queue adapter with `:
|
642
|
+
- Allow configuration of Rails queue adapter with `:good_job` [\#28](https://github.com/bensheldon/good_job/pull/28) ([bensheldon](https://github.com/bensheldon))
|
543
643
|
|
544
644
|
## [v0.5.0](https://github.com/bensheldon/good_job/tree/v0.5.0) (2020-07-13)
|
545
645
|
|
data/README.md
CHANGED
@@ -36,7 +36,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
36
36
|
- [`good_job start`](#good_job-start)
|
37
37
|
- [`good_job cleanup_preserved_jobs`](#good_job-cleanup_preserved_jobs)
|
38
38
|
- [Configuration options](#configuration-options)
|
39
|
-
- [Global options](#global-options)
|
39
|
+
- [Global options](#global-options)
|
40
40
|
- [Dashboard](#dashboard)
|
41
41
|
- [Go deeper](#go-deeper)
|
42
42
|
- [Exceptions, retries, and reliability](#exceptions-retries-and-reliability)
|
@@ -119,10 +119,10 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
119
119
|
- GoodJob can also be configured to execute jobs within the web server process to save on resources. This is useful for low-workloads when economy is paramount.
|
120
120
|
|
121
121
|
```
|
122
|
-
$ GOOD_JOB_EXECUTION_MODE=
|
122
|
+
$ GOOD_JOB_EXECUTION_MODE=async_server rails server
|
123
123
|
```
|
124
124
|
|
125
|
-
Additional configuration is likely necessary, see the reference below for
|
125
|
+
Additional configuration is likely necessary, see the reference below for f configuration.
|
126
126
|
|
127
127
|
## Compatibility
|
128
128
|
|
@@ -206,7 +206,7 @@ Additional configuration can be provided via `config.good_job.OPTION = ...` for
|
|
206
206
|
config.active_job.queue_adapter = :good_job
|
207
207
|
|
208
208
|
# Configure options individually...
|
209
|
-
config.good_job.execution_mode = :
|
209
|
+
config.good_job.execution_mode = :async_server
|
210
210
|
config.good_job.max_threads = 5
|
211
211
|
config.good_job.poll_interval = 30 # seconds
|
212
212
|
config.good_job.shutdown_timeout = 25 # seconds
|
@@ -214,7 +214,7 @@ config.good_job.shutdown_timeout = 25 # seconds
|
|
214
214
|
|
215
215
|
# ...or all at once.
|
216
216
|
config.good_job = {
|
217
|
-
execution_mode: :
|
217
|
+
execution_mode: :async_server,
|
218
218
|
max_threads: 5,
|
219
219
|
poll_interval: 30,
|
220
220
|
shutdown_timeout: 25,
|
@@ -226,10 +226,11 @@ Available configuration options are:
|
|
226
226
|
- `execution_mode` (symbol) specifies how and where jobs should be executed. You can also set this with the environment variable `GOOD_JOB_EXECUTION_MODE`. It can be any one of:
|
227
227
|
- `:inline` executes jobs immediately in whatever process queued them (usually the web server process). This should only be used in test and development environments.
|
228
228
|
- `:external` causes the adapter to enqueue jobs, but not execute them. When using this option (the default for production environments), you’ll need to use the command-line tool to actually execute your jobs.
|
229
|
-
- `:
|
230
|
-
- `
|
231
|
-
- `
|
232
|
-
- `
|
229
|
+
- `:async_server` executes jobs in separate threads within the Rails webserver process (`bundle exec rails server`). It can be more economical for small workloads because you don’t need a separate machine or environment for running your jobs, but if your web server is under heavy load or your jobs require a lot of resources, you should choose `:external` instead. When not in the Rails webserver, jobs will execute in `:external` mode to ensure jobs are not executed within `rails console`, `rails db:migrate`, `rails assets:prepare`, etc.
|
230
|
+
- `:async` executes jobs in separate threads in _any_ Rails process.
|
231
|
+
- `max_threads` (integer) sets the maximum number of threads to use when `execution_mode` is set to `:async` or `:async_server`. You can also set this with the environment variable `GOOD_JOB_MAX_THREADS`.
|
232
|
+
- `queues` (string) determines which queues to execute jobs from when `execution_mode` is set to `:async` or `:async_server`. See the description of `good_job start` for more details on the format of this string. You can also set this with the environment variable `GOOD_JOB_QUEUES`.
|
233
|
+
- `poll_interval` (integer) sets the number of seconds between polls for jobs when `execution_mode` is set to `:async` or `:async_server`. You can also set this with the environment variable `GOOD_JOB_POLL_INTERVAL`.
|
233
234
|
- `max_cache` (integer) sets the maximum number of scheduled jobs that will be stored in memory to reduce execution latency when also polling for scheduled jobs. Caching 10,000 scheduled jobs uses approximately 20MB of memory. You can also set this with the environment variable `GOOD_JOB_MAX_CACHE`.
|
234
235
|
- `shutdown_timeout` (float) number of seconds to wait for jobs to finish when shutting down before stopping the thread. Defaults to forever: `-1`. You can also set this with the environment variable `GOOD_JOB_SHUTDOWN_TIMEOUT`.
|
235
236
|
|
@@ -254,6 +255,7 @@ config.good_job.execution_mode = :external
|
|
254
255
|
|
255
256
|
Good Job’s general behavior can also be configured via several attributes directly on the `GoodJob` module:
|
256
257
|
|
258
|
+
- **`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._
|
257
259
|
- **`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`.
|
258
260
|
- **`GoodJob.preserve_job_records`** (boolean) keeps job records in your database even after jobs are completed. (Default: `false`)
|
259
261
|
- **`GoodJob.retry_on_unhandled_error`** (boolean) causes jobs to be re-queued and retried if they raise an instance of `StandardError`. Instances of `Exception`, like SIGINT, will *always* be retried, regardless of this attribute’s value. (Default: `true`)
|
@@ -263,6 +265,7 @@ You’ll generally want to configure these in `config/initializers/good_job.rb`,
|
|
263
265
|
|
264
266
|
```ruby
|
265
267
|
# config/initializers/good_job.rb
|
268
|
+
GoodJob.active_record_parent_class = "ApplicationRecord"
|
266
269
|
GoodJob.preserve_job_records = true
|
267
270
|
GoodJob.retry_on_unhandled_error = false
|
268
271
|
GoodJob.on_thread_error = -> (exception) { Raven.capture_exception(exception) }
|
@@ -485,11 +488,11 @@ GoodJob can execute jobs "async" in the same process as the webserver (e.g. `bin
|
|
485
488
|
config.active_job.queue_adapter = :good_job
|
486
489
|
|
487
490
|
# To change the execution mode
|
488
|
-
config.good_job.execution_mode = :
|
491
|
+
config.good_job.execution_mode = :async_server
|
489
492
|
|
490
493
|
# Or with more configuration
|
491
494
|
config.good_job = {
|
492
|
-
execution_mode: :
|
495
|
+
execution_mode: :async_server,
|
493
496
|
max_threads: 4,
|
494
497
|
poll_interval: 30
|
495
498
|
}
|
@@ -498,7 +501,7 @@ GoodJob can execute jobs "async" in the same process as the webserver (e.g. `bin
|
|
498
501
|
- Or, with environment variables:
|
499
502
|
|
500
503
|
```bash
|
501
|
-
$ GOOD_JOB_EXECUTION_MODE=
|
504
|
+
$ GOOD_JOB_EXECUTION_MODE=async_server GOOD_JOB_MAX_THREADS=4 GOOD_JOB_POLL_INTERVAL=30 bin/rails server
|
502
505
|
```
|
503
506
|
|
504
507
|
Depending on your application configuration, you may need to take additional steps:
|
@@ -12,17 +12,18 @@ module GoodJob
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def jobs
|
15
|
-
|
15
|
+
after_scheduled_at = params[:after_scheduled_at].present? ? Time.zone.parse(params[:after_scheduled_at]) : nil
|
16
|
+
sql = GoodJob::Job.display_all(after_scheduled_at: after_scheduled_at, after_id: params[:after_id])
|
16
17
|
.limit(params.fetch(:limit, 10))
|
17
|
-
|
18
|
-
sql = sql.where("serialized_params->>'job_class' = ?", params[:job_class])
|
19
|
-
end
|
18
|
+
sql = sql.with_job_class(params[:job_class]) if params[:job_class]
|
20
19
|
if params[:state]
|
21
20
|
case params[:state]
|
22
21
|
when 'finished'
|
23
22
|
sql = sql.finished
|
24
23
|
when 'unfinished'
|
25
24
|
sql = sql.unfinished
|
25
|
+
when 'running'
|
26
|
+
sql = sql.running
|
26
27
|
when 'errors'
|
27
28
|
sql = sql.where.not(error: nil)
|
28
29
|
end
|
@@ -34,6 +35,7 @@ module GoodJob
|
|
34
35
|
{
|
35
36
|
'finished' => GoodJob::Job.finished.count,
|
36
37
|
'unfinished' => GoodJob::Job.unfinished.count,
|
38
|
+
'running' => GoodJob::Job.running.count,
|
37
39
|
'errors' => GoodJob::Job.where.not(error: nil).count,
|
38
40
|
}
|
39
41
|
end
|
@@ -79,7 +81,7 @@ module GoodJob
|
|
79
81
|
queue_names = job_data.map { |d| d['queue_name'] }.uniq
|
80
82
|
labels = []
|
81
83
|
queues_data = job_data.to_a.group_by { |d| d['timestamp'] }.each_with_object({}) do |(timestamp, values), hash|
|
82
|
-
labels << timestamp
|
84
|
+
labels << timestamp.in_time_zone.to_s
|
83
85
|
queue_names.each do |queue_name|
|
84
86
|
(hash[queue_name] ||= []) << values.find { |d| d['queue_name'] == queue_name }&.[]('count')
|
85
87
|
end
|
@@ -6,11 +6,12 @@
|
|
6
6
|
fullWidth: true,
|
7
7
|
chartPadding: {
|
8
8
|
right: 40,
|
9
|
-
top: 20
|
9
|
+
top: 20,
|
10
|
+
bottom: 20
|
10
11
|
},
|
11
12
|
axisX: {
|
12
13
|
labelInterpolationFnc: function(value, index) {
|
13
|
-
return index % 3
|
14
|
+
return index % 3 === 0 ? value : null;
|
14
15
|
}
|
15
16
|
},
|
16
17
|
axisY: {
|
data/exe/good_job
CHANGED
@@ -2,10 +2,6 @@ module ActiveJob # :nodoc:
|
|
2
2
|
module QueueAdapters # :nodoc:
|
3
3
|
# See {GoodJob::Adapter} for details.
|
4
4
|
class GoodJobAdapter < GoodJob::Adapter
|
5
|
-
def initialize(**options)
|
6
|
-
configuration = GoodJob::Configuration.new(options, env: ENV)
|
7
|
-
super(**options.merge(execution_mode: configuration.rails_execution_mode))
|
8
|
-
end
|
9
5
|
end
|
10
6
|
end
|
11
7
|
end
|
data/lib/good_job.rb
CHANGED
@@ -17,11 +17,20 @@ require "good_job/railtie"
|
|
17
17
|
#
|
18
18
|
# +GoodJob+ is the top-level namespace and exposes configuration attributes.
|
19
19
|
module GoodJob
|
20
|
+
# @!attribute [rw] active_record_parent_class
|
21
|
+
# @!scope class
|
22
|
+
# The ActiveRecord parent class inherited by +GoodJob::Job+ (default: +ActiveRecord::Base+).
|
23
|
+
# Use this when using multiple databases or other custom ActiveRecord configuration.
|
24
|
+
# @return [ActiveRecord::Base]
|
25
|
+
# @example Change the base class:
|
26
|
+
# GoodJob.active_record_parent_class = "CustomApplicationRecord"
|
27
|
+
mattr_accessor :active_record_parent_class, default: "ActiveRecord::Base"
|
28
|
+
|
20
29
|
# @!attribute [rw] logger
|
21
30
|
# @!scope class
|
22
31
|
# The logger used by GoodJob (default: +Rails.logger+).
|
23
32
|
# Use this to redirect logs to a special location or file.
|
24
|
-
# @return [Logger]
|
33
|
+
# @return [Logger, nil]
|
25
34
|
# @example Output GoodJob logs to a file:
|
26
35
|
# GoodJob.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/my_logs.log"))
|
27
36
|
mattr_accessor :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout))
|
@@ -33,7 +42,7 @@ module GoodJob
|
|
33
42
|
# If you want to preserve jobs for latter inspection, set this to +true+.
|
34
43
|
# If you want to preserve only jobs that finished with error for latter inspection, set this to +:on_unhandled_error+.
|
35
44
|
# If +true+, you will need to clean out jobs using the +good_job cleanup_preserved_jobs+ CLI command.
|
36
|
-
# @return [Boolean]
|
45
|
+
# @return [Boolean, nil]
|
37
46
|
mattr_accessor :preserve_job_records, default: false
|
38
47
|
|
39
48
|
# @!attribute [rw] retry_on_unhandled_error
|
@@ -42,10 +51,11 @@ module GoodJob
|
|
42
51
|
# If +true+, causes jobs to be re-queued and retried if they raise an instance of +StandardError+.
|
43
52
|
# If +false+, jobs will be discarded or marked as finished if they raise an instance of +StandardError+.
|
44
53
|
# Instances of +Exception+, like +SIGINT+, will *always* be retried, regardless of this attribute's value.
|
45
|
-
# @return [Boolean]
|
54
|
+
# @return [Boolean, nil]
|
46
55
|
mattr_accessor :retry_on_unhandled_error, default: true
|
47
56
|
|
48
57
|
# @deprecated Use {GoodJob#retry_on_unhandled_error} instead.
|
58
|
+
# @return [Boolean, nil]
|
49
59
|
def self.reperform_jobs_on_standard_error
|
50
60
|
ActiveSupport::Deprecation.warn(
|
51
61
|
"Calling 'GoodJob.reperform_jobs_on_standard_error' is deprecated. Please use 'retry_on_unhandled_error'"
|
@@ -54,6 +64,8 @@ module GoodJob
|
|
54
64
|
end
|
55
65
|
|
56
66
|
# @deprecated Use {GoodJob#retry_on_unhandled_error=} instead.
|
67
|
+
# @param value [Boolean]
|
68
|
+
# @return [Boolean]
|
57
69
|
def self.reperform_jobs_on_standard_error=(value)
|
58
70
|
ActiveSupport::Deprecation.warn(
|
59
71
|
"Setting 'GoodJob.reperform_jobs_on_standard_error=' is deprecated. Please use 'retry_on_unhandled_error='"
|
@@ -68,7 +80,7 @@ module GoodJob
|
|
68
80
|
# @example Send errors to Sentry
|
69
81
|
# # config/initializers/good_job.rb
|
70
82
|
# GoodJob.on_thread_error = -> (exception) { Raven.capture_exception(exception) }
|
71
|
-
# @return [
|
83
|
+
# @return [Proc, nil]
|
72
84
|
mattr_accessor :on_thread_error, default: nil
|
73
85
|
|
74
86
|
# Stop executing jobs.
|
@@ -76,16 +88,21 @@ module GoodJob
|
|
76
88
|
# When forking processes you should shut down these background threads before forking, and restart them after forking.
|
77
89
|
# For example, you should use +shutdown+ and +restart+ when using async execution mode with Puma.
|
78
90
|
# See the {file:README.md#executing-jobs-async--in-process} for more explanation and examples.
|
91
|
+
# @param timeout [nil, Numeric] Seconds to wait for actively executing jobs to finish
|
92
|
+
# * +nil+, the scheduler will trigger a shutdown but not wait for it to complete.
|
93
|
+
# * +-1+, the scheduler will wait until the shutdown is complete.
|
94
|
+
# * +0+, the scheduler will immediately shutdown and stop any active tasks.
|
95
|
+
# * +1..+, the scheduler will wait that many seconds before stopping any remaining active tasks.
|
79
96
|
# @param wait [Boolean] whether to wait for shutdown
|
80
97
|
# @return [void]
|
81
98
|
def self.shutdown(timeout: -1, wait: nil)
|
82
|
-
timeout = if wait.
|
99
|
+
timeout = if wait.nil?
|
100
|
+
timeout
|
101
|
+
else
|
83
102
|
ActiveSupport::Deprecation.warn(
|
84
103
|
"Using `GoodJob.shutdown` with `wait:` kwarg is deprecated; use `timeout:` kwarg instead e.g. GoodJob.shutdown(timeout: #{wait ? '-1' : 'nil'})"
|
85
104
|
)
|
86
105
|
wait ? -1 : nil
|
87
|
-
else
|
88
|
-
timeout
|
89
106
|
end
|
90
107
|
|
91
108
|
executables = Array(Notifier.instances) + Array(Poller.instances) + Array(Scheduler.instances)
|
@@ -105,6 +122,7 @@ module GoodJob
|
|
105
122
|
# When forking processes you should shut down these background threads before forking, and restart them after forking.
|
106
123
|
# For example, you should use +shutdown+ and +restart+ when using async execution mode with Puma.
|
107
124
|
# See the {file:README.md#executing-jobs-async--in-process} for more explanation and examples.
|
125
|
+
# @param timeout [Numeric, nil] Seconds to wait for active threads to finish.
|
108
126
|
# @return [void]
|
109
127
|
def self.restart(timeout: -1)
|
110
128
|
executables = Array(Notifier.instances) + Array(Poller.instances) + Array(Scheduler.instances)
|
@@ -112,7 +130,7 @@ module GoodJob
|
|
112
130
|
end
|
113
131
|
|
114
132
|
# Sends +#shutdown+ or +#restart+ to executable objects ({GoodJob::Notifier}, {GoodJob::Poller}, {GoodJob::Scheduler})
|
115
|
-
# @param executables [Array<
|
133
|
+
# @param executables [Array<Notifier, Poller, Scheduler, MultiScheduler>] Objects to shut down.
|
116
134
|
# @param method_name [:symbol] Method to call, e.g. +:shutdown+ or +:restart+.
|
117
135
|
# @param timeout [nil,Numeric]
|
118
136
|
# @return [void]
|