rocketjob 3.0.1 → 3.0.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
  SHA1:
3
- metadata.gz: a8f3f4b74a0c8fc21434e841b045e285474d2508
4
- data.tar.gz: 9b1a0c551b00e0470f7f0cf524d0b24c493df900
3
+ metadata.gz: 2c812dcc683d598eef994060ede4cfcdeacd0cb0
4
+ data.tar.gz: e47aba9440145857bdce60e42801696971201632
5
5
  SHA512:
6
- metadata.gz: 36c29026484cb8f60930318609c94c31044231bb43c53cac55185f89b6479e5446a53522e49bac5bad86506988338fdca48b8f67b2094209b93a144c355d1ff8
7
- data.tar.gz: 333637778b2cd085e5ea58b1852e57626859e8499918cfd48af4e2dfac893792c5f9619b42070ec0303209ef9287f9e50d281060a92f4e07bcd2461b434e3c6c
6
+ metadata.gz: ff08de7a9e29d252e8329966fe508ead35e0c883bac0ab77eab50a94e0404fbd5e4d790619afe626b9611e6edf767e70d08b67853cf10dd68c7d00267688d02b
7
+ data.tar.gz: 6c95b4d77dba6fb156e2f41714b815ddc8faa503b75bea41df82fbc47197654be9686092a65bfd32a876937fd231ed3cfb82b80e224b97d0ac505c99e55ec361
@@ -27,7 +27,7 @@ module RocketJob
27
27
  # Requeues all jobs for which the workers have disappeared
28
28
  def self.requeue_zombies
29
29
  all.each do |active_worker|
30
- next if !active_worker.zombie? || !active_worker.job.may_requeue?
30
+ next if !active_worker.zombie? || !active_worker.job.may_requeue?(active_worker.server_name)
31
31
  active_worker.job.requeue!(active_worker.server_name)
32
32
  end
33
33
  end
@@ -1,5 +1,4 @@
1
1
  require 'yaml'
2
- # encoding: UTF-8
3
2
  module RocketJob
4
3
  # Centralized Configuration for Rocket Jobs
5
4
  class Config
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module RocketJob
3
2
  # Heartbeat
4
3
  #
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module RocketJob
3
2
  # The base job from which all jobs are created
4
3
  class Job
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module RocketJob
3
2
  class JobException
4
3
  include Plugins::Document
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  # Worker behavior for a job
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -46,19 +45,34 @@ module RocketJob
46
45
 
47
46
  # Copy across run_at for future dated jobs
48
47
  attrs['run_at'] = run_at if run_at && (run_at > Time.now)
49
- # Allow Singleton to prevent the creation of a new job if one is already running
50
- job = self.class.create(attrs)
51
- if job.persisted?
52
- logger.info("Started a new job instance: #{job.id}")
53
- else
54
- logger.info('New job instance not started since one is already active')
55
- end
48
+
49
+ rocket_job_restart_create(attrs)
56
50
  end
57
51
 
58
52
  def rocket_job_restart_abort
59
53
  new_record? ? abort : abort!
60
54
  end
61
55
 
56
+ # Allow Singleton to prevent the creation of a new job if one is already running
57
+ # Retry since the delete may not have persisted to disk yet.
58
+ def rocket_job_restart_create(attrs, retry_limit = 3, sleep_interval = 0.1)
59
+ count = 0
60
+ while count < retry_limit
61
+ job = self.class.create(attrs)
62
+ if job.persisted?
63
+ logger.info("Started a new job instance: #{job.id}")
64
+ return true
65
+ else
66
+ logger.info('Job already active, retrying after a short sleep')
67
+ sleep(sleep_interval)
68
+ end
69
+ count += 1
70
+ end
71
+ logger.warn('New job instance not started since one is already active')
72
+ false
73
+ end
74
+
75
+
62
76
  end
63
77
  end
64
78
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'active_support/concern'
3
2
 
4
3
  module RocketJob
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'thread'
3
2
  require 'active_support/concern'
4
3
  require 'aasm'
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'concurrent'
3
2
  module RocketJob
4
3
  # Server
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module RocketJob #:nodoc
3
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
4
3
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'concurrent'
3
2
  require 'forwardable'
4
3
  module RocketJob
data/lib/rocketjob.rb CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'semantic_logger'
3
2
  require 'mongoid'
4
3
  require 'rocket_job/extensions/mongo/logging'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.3'
69
- - !ruby/object:Gem::Dependency
70
- name: mongo_ha
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.0'
83
69
  description:
84
70
  email:
85
71
  - support@rocketjob.io