allora 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,6 +44,7 @@ module Allora
44
44
  @interval = opts.fetch(:interval, 0.333)
45
45
  @logger = opts.fetch(:logger, default_logger)
46
46
  @jobs = {}
47
+ @shutdown = false
47
48
  end
48
49
 
49
50
  # Register a new job for the given options.
@@ -73,6 +74,8 @@ module Allora
73
74
  def start
74
75
  log "Starting scheduler process, using #{@backend.class}"
75
76
 
77
+ %w[TERM INT QUIT].each { |sig| Signal.trap(sig) { stop } }
78
+
76
79
  @thread = Thread.new do
77
80
  loop do
78
81
  @backend.reschedule(@jobs).each do |name, job|
@@ -80,6 +83,8 @@ module Allora
80
83
  job.execute
81
84
  end
82
85
 
86
+ Thread.exit if @shutdown
87
+
83
88
  sleep(@interval)
84
89
  end
85
90
  end
@@ -88,7 +93,7 @@ module Allora
88
93
  # Stop the currently running scheduler Thread
89
94
  def stop
90
95
  log "Exiting scheduler process"
91
- @thread.exit
96
+ @shutdown = true
92
97
  end
93
98
 
94
99
  # Join the currently running scheduler Thread.
@@ -22,5 +22,5 @@
22
22
  ##
23
23
 
24
24
  module Allora
25
- VERSION = "0.0.4"
25
+ VERSION = "0.0.5"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70230789646860 !ruby/object:Gem::Requirement
16
+ requirement: &70208371243600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70230789646860
24
+ version_requirements: *70208371243600
25
25
  description: ! "Allora (Italian for \"at that time\") provides a replacement for the
26
26
  classic UNIX\n cron, using nothing but ruby. It is very small,
27
27
  easy to follow and relatively\n feature-light. It does support