good_job 3.15.11 → 3.15.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 983b4d8a2381c6564ab48334b2587ae33dee8cf1385d72456f29caf8dd99e26d
4
- data.tar.gz: fd4a54679b61b925f3c0fe6eb07d490f6b92014e2b7a12ac869f77c4c32482e2
3
+ metadata.gz: 8ba9a6bb5f97a64b3ff00e48501cbebf617372e0983c5f87f14bfe25898625b1
4
+ data.tar.gz: 673df26ced6db84ea48e77c736d8969216497034d0c19ba3f32016fd0b915afd
5
5
  SHA512:
6
- metadata.gz: 3d2d8be450c7f282e6b59c6a4730ab0eebb77c2f8c45eadf0fe556b6490b6b6e38cb247e205da275930f6bd2c4a5d23e844088004a13454e2286af72a001c095
7
- data.tar.gz: 61764d8612c50fa00ea2c5aadf2d2d5ea365f771cb43aedc87bc7456d0d2a1381a3985a518ffeecd382bec27b838ce423268175e0b68687a6722ef77d2b38f88
6
+ metadata.gz: 9b39c600a8cb22842c8f2aee4b952695fad309fafb522f16f74ad9b21c20a9db4e9ff05ea13647024c1cbbb95438168cd620be89fb766605419de21e876a2ce8
7
+ data.tar.gz: 8469a0079df3bd25aa8f8474fa5cffe8a67ad7fa91efa70b7e2ebcba50e5132a1880c004e5e6bca2aa3dc12fe844a7cf4219c443644b86c7dde839833a12ab1f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.15.12](https://github.com/bensheldon/good_job/tree/v3.15.12) (2023-06-11)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.15.11...v3.15.12)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Do not allow GoodJob to automatically start after Rails initialization if previously shutdown [\#976](https://github.com/bensheldon/good_job/pull/976) ([bensheldon](https://github.com/bensheldon))
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Fix Rubocop linting [\#975](https://github.com/bensheldon/good_job/pull/975) ([bensheldon](https://github.com/bensheldon))
14
+ - Bump capybara from 3.38.0 to 3.39.1 [\#970](https://github.com/bensheldon/good_job/pull/970) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+ - Bump thor from 1.2.1 to 1.2.2 [\#967](https://github.com/bensheldon/good_job/pull/967) ([dependabot[bot]](https://github.com/apps/dependabot))
16
+
3
17
  ## [v3.15.11](https://github.com/bensheldon/good_job/tree/v3.15.11) (2023-06-06)
4
18
 
5
19
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.15.10...v3.15.11)
@@ -7,6 +7,9 @@ module GoodJob # :nodoc:
7
7
  include AssignableConnection
8
8
  include Lockable
9
9
 
10
+ STALE_INTERVAL = 30.seconds
11
+ EXPIRED_INTERVAL = 5.minutes
12
+
10
13
  self.table_name = 'good_job_processes'
11
14
 
12
15
  cattr_reader :mutex, default: Mutex.new
@@ -76,5 +79,21 @@ module GoodJob # :nodoc:
76
79
  def basename
77
80
  File.basename(state["proctitle"])
78
81
  end
82
+
83
+ def refresh
84
+ touch(:updated_at) # rubocop:disable Rails/SkipsModelValidations
85
+ end
86
+
87
+ def refresh_if_stale
88
+ refresh if stale?
89
+ end
90
+
91
+ def stale?
92
+ updated_at < STALE_INTERVAL.ago
93
+ end
94
+
95
+ def expired?
96
+ updated_at < EXPIRED_INTERVAL.ago
97
+ end
79
98
  end
80
99
  end
@@ -15,17 +15,18 @@ module GoodJob
15
15
  self.class.instances << self
16
16
  @configuration = configuration
17
17
 
18
- @autostart = true
18
+ @startable = true
19
19
  @running = false
20
20
  @mutex = Mutex.new
21
21
  end
22
22
 
23
- # Start executing jobs (if not already running).
24
- def start
25
- return if @running
23
+ # Start the capsule once. After a shutdown, {#restart} must be used to start again.
24
+ # @return [nil, Boolean] Whether the capsule was started.
25
+ def start(force: false)
26
+ return unless startable?(force: force)
26
27
 
27
28
  @mutex.synchronize do
28
- return if @running
29
+ return unless startable?(force: force)
29
30
 
30
31
  @notifier = GoodJob::Notifier.new(enable_listening: @configuration.enable_listen_notify)
31
32
  @poller = GoodJob::Poller.new(poll_interval: @configuration.poll_interval)
@@ -35,7 +36,7 @@ module GoodJob
35
36
 
36
37
  @cron_manager = GoodJob::CronManager.new(@configuration.cron_entries, start_on_initialize: true) if @configuration.enable_cron?
37
38
 
38
- @autostart = false
39
+ @startable = false
39
40
  @running = true
40
41
  end
41
42
  end
@@ -50,7 +51,7 @@ module GoodJob
50
51
  def shutdown(timeout: :default)
51
52
  timeout = timeout == :default ? @configuration.shutdown_timeout : timeout
52
53
  GoodJob._shutdown_all([@notifier, @poller, @scheduler, @cron_manager].compact, timeout: timeout)
53
- @autostart = false
54
+ @startable = false
54
55
  @running = false
55
56
  end
56
57
 
@@ -61,7 +62,7 @@ module GoodJob
61
62
  raise ArgumentError, "Capsule#restart cannot be called with a timeout of nil" if timeout.nil?
62
63
 
63
64
  shutdown(timeout: timeout)
64
- start
65
+ start(force: true)
65
66
  end
66
67
 
67
68
  # @return [Boolean] Whether the capsule is currently running.
@@ -76,10 +77,16 @@ module GoodJob
76
77
 
77
78
  # Creates an execution thread(s) with the given attributes.
78
79
  # @param job_state [Hash, nil] See {GoodJob::Scheduler#create_thread}.
79
- # @return [Boolean, nil] Whether work was started.
80
+ # @return [Boolean, nil] Whether the thread was created.
80
81
  def create_thread(job_state = nil)
81
- start if !running? && @autostart
82
+ start if startable?
82
83
  @scheduler&.create_thread(job_state)
83
84
  end
85
+
86
+ private
87
+
88
+ def startable?(force: false)
89
+ !@running && (@startable || force)
90
+ end
84
91
  end
85
92
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '3.15.11'
4
+ VERSION = '3.15.12'
5
5
 
6
6
  # GoodJob version as Gem::Version object
7
7
  GEM_VERSION = Gem::Version.new(VERSION)
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.15.11
4
+ version: 3.15.12
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-06-06 00:00:00.000000000 Z
11
+ date: 2023-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob