good_job 0.2.1 → 0.2.2

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: 66c19e40862f09e5c7816911c0a21e8cb88f036980a9c33df62cba058b3993e5
4
- data.tar.gz: 218153476e92ca847e7279d9979c4396ed02f36a41918b32b58bf1fb17b8cd92
3
+ metadata.gz: a808beca38372ee8dcd23871600c9ed9b0181aa7756656c46e0382e9eef927b0
4
+ data.tar.gz: 7fa59a1e31b4e720149ed19009f91691e840096570d38e519d37eb9b930cb655
5
5
  SHA512:
6
- metadata.gz: d5b0305c889392d2879ccd818eb98b09a867d85a5b853dc8ec35b5a17fee3490cc082f032827f631b15e0a8e1143ea676eea05738d901f97ec4737adf0a514d0
7
- data.tar.gz: 96a8537b85de48b07f676746642bb43ff18369db559b0c058c21d101a7740a0269a772a3b8629fefe3242d2e8a1df0d34a0f12b85b5928caf6272572fcff0d67
6
+ metadata.gz: 9ce51a00e0aeabbd2be39e796168343d0daf96b368cb75ae8011f05bec891fcab820323189c43c79b97ae5a4c2586a7ec4996cd68717a83bb66613b7db523a95
7
+ data.tar.gz: d0cb6bc52ba43a1e86a4ba12a8a09204d90f3b393de0d0dc54de64de37c85290f8228362e76f8c023a0d78f28d63706b4c8f2b04626134bc4240d9ad055544db
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/bensheldon/good_job/tree/HEAD)
3
+ ## [0.2.2](https://github.com/bensheldon/good_job/tree/0.2.2) (2020-03-07)
4
4
 
5
- [Full Changelog](https://github.com/bensheldon/good_job/compare/v0.2.0...HEAD)
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v0.2.1...0.2.2)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Gracefully shutdown Scheduler when executable receives TERM or INT [\#17](https://github.com/bensheldon/good_job/pull/17) ([bensheldon](https://github.com/bensheldon))
10
+ - Update Appraisals [\#16](https://github.com/bensheldon/good_job/pull/16) ([bensheldon](https://github.com/bensheldon))
11
+
12
+ ## [v0.2.1](https://github.com/bensheldon/good_job/tree/v0.2.1) (2020-03-07)
13
+
14
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v0.2.0...v0.2.1)
6
15
 
7
16
  **Merged pull requests:**
8
17
 
data/lib/good_job/cli.rb CHANGED
@@ -8,11 +8,23 @@ module GoodJob
8
8
  def start
9
9
  require RAILS_ENVIRONMENT_RB
10
10
 
11
- GoodJob::Scheduler.new
11
+ scheduler = GoodJob::Scheduler.new
12
+
13
+ %w[INT TERM].each do |signal|
14
+ trap(signal) { @stop_good_job_executable = true }
15
+ end
16
+ @stop_good_job_executable = false
17
+
18
+ $stdout.puts "GoodJob waiting for jobs..."
12
19
 
13
20
  Kernel.loop do
14
- sleep 1
21
+ sleep 0.1
22
+ break if @stop_good_job_executable || scheduler.shutdown?
15
23
  end
24
+
25
+ $stdout.puts "\nFinishing GoodJob's current jobs before exiting..."
26
+ scheduler.shutdown
27
+ $stdout.puts "GoodJob's jobs finished, exiting..."
16
28
  end
17
29
 
18
30
  default_task :start
@@ -42,6 +42,18 @@ module GoodJob
42
42
  end
43
43
  end
44
44
 
45
+ def scheduler_start_shutdown(_event)
46
+ info do
47
+ "Shutting down scheduler..."
48
+ end
49
+ end
50
+
51
+ def scheduler_shutdown(_event)
52
+ info do
53
+ "Scheduler is shut down."
54
+ end
55
+ end
56
+
45
57
  private
46
58
 
47
59
  def logger
@@ -42,17 +42,24 @@ module GoodJob
42
42
  end
43
43
 
44
44
  def shutdown(wait: true)
45
- if @timer.running?
46
- @timer.shutdown
47
- @timer.wait_for_termination if wait
48
- end
45
+ @_shutdown = true
46
+
47
+ ActiveSupport::Notifications.instrument("scheduler_start_shutdown.good_job", { wait: wait })
48
+ ActiveSupport::Notifications.instrument("scheduler_shutdown.good_job", { wait: wait }) do
49
+ if @timer.running?
50
+ @timer.shutdown
51
+ @timer.wait_for_termination if wait
52
+ end
49
53
 
50
- if @pool.running?
51
- @pool.shutdown
52
- @pool.wait_for_termination if wait
54
+ if @pool.running?
55
+ @pool.shutdown
56
+ @pool.wait_for_termination if wait
57
+ end
53
58
  end
59
+ end
54
60
 
55
- true
61
+ def shutdown?
62
+ @_shutdown
56
63
  end
57
64
 
58
65
  def create_thread
@@ -1,3 +1,3 @@
1
1
  module GoodJob
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
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: 0.2.1
4
+ version: 0.2.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: 2020-03-07 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby