simple_job 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,8 @@
1
1
  = Simple Job
2
2
 
3
+ == Version 0.6.1
4
+ * Updating :asynchronous_execute option to fork a separate process
5
+
3
6
  == Version 0.6.0
4
7
  * Added #logger method to classes that include JobDefinition and instances of that class; it returns a logger wrapper that:
5
8
  * Wraps and uses JobQueue.config[:logger]
@@ -39,7 +39,7 @@ class SQSJobQueue < JobQueue
39
39
  #
40
40
  # The :asynchronous_execute option, if set to true, will cause the poll method to
41
41
  # parse and immediately accept each message (if it's validly formatted). It will
42
- # then execute the proper job (outside the receive_message block). This can be
42
+ # then fork and execute the proper job in a separate process. This can be
43
43
  # used when you have long-running jobs that will exceed the visibility timeout,
44
44
  # and it is not critical that they be retried when they fail.
45
45
  def self.define_queue(type, options = {})
@@ -168,15 +168,28 @@ class SQSJobQueue < JobQueue
168
168
  end
169
169
 
170
170
  # NOTE: only executes if asynchronous_execute is set (after message has been confirmed)
171
- message_handler.call(last_definition, last_message) if asynchronous_execute && last_message
172
-
173
- log_execution(true, last_message, current_job_type, current_start_milliseconds)
171
+ if asynchronous_execute && last_message
172
+ pid = fork
173
+ if pid
174
+ # in parent
175
+ Process.detach pid
176
+ else
177
+ # in child
178
+ message_handler.call(last_definition, last_message)
179
+ log_execution(true, last_message, current_job_type, current_start_milliseconds)
180
+ exit
181
+ end
182
+ else
183
+ log_execution(true, last_message, current_job_type, current_start_milliseconds)
184
+ end
174
185
 
175
186
  break if options[:idle_timeout] && ((Time.now - last_message_at) > options[:idle_timeout])
176
187
 
177
188
  unless last_message
178
189
  Kernel.sleep(options[:poll_interval]) unless options[:poll_interval] == 0
179
190
  end
191
+ rescue SystemExit => e
192
+ raise e
180
193
  rescue Exception => e
181
194
  log_execution(false, last_message, current_job_type, current_start_milliseconds) rescue nil
182
195
 
@@ -1,3 +1,3 @@
1
1
  module SimpleJob
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_job
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Dawson