rocketjob 2.0.0.rc1 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocket_job/cli.rb +1 -1
- data/lib/rocket_job/extensions/mongo.rb +1 -1
- data/lib/rocket_job/jobs/simple_job.rb +0 -1
- data/lib/rocket_job/plugins/job/persistence.rb +22 -23
- data/lib/rocket_job/plugins/job/worker.rb +3 -1
- data/lib/rocket_job/version.rb +1 -1
- data/lib/rocket_job/worker.rb +2 -4
- data/test/test_helper.rb +5 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eb90dc1e3aea713b4d981636208f44a0da52e6c
|
4
|
+
data.tar.gz: 1f9f590f2789f050d736af772843b78bd98d1795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab4508ac667d557a4eee4533d4bdbb15c8bb6b10c35a8f9f1f71e53e33f0a1276c7b55b6ba80743169efd19bc6f240311e678a527cdd469a5bed52d45406e66
|
7
|
+
data.tar.gz: 201ed97e4992979ada9af839f6951c5c3f8ae373ce6a93d07d6356571f07fc91b5319b8eb2915e2c1dc6be50ef56d845136479db17f7907528ffdf9822bda01a
|
data/lib/rocket_job/cli.rb
CHANGED
@@ -131,7 +131,7 @@ module RocketJob
|
|
131
131
|
# Parse command line options placing results in the corresponding instance variables
|
132
132
|
def parse(argv)
|
133
133
|
parser = OptionParser.new do |o|
|
134
|
-
o.on('-n', '--name NAME', 'Unique Name of this worker instance (Default:
|
134
|
+
o.on('-n', '--name NAME', 'Unique Name of this worker instance (Default: host_name:PID)') do |arg|
|
135
135
|
@name = arg
|
136
136
|
end
|
137
137
|
o.on('-t', '--threads COUNT', 'Number of worker threads to start') do |arg|
|
@@ -35,38 +35,37 @@ module RocketJob
|
|
35
35
|
# skip_job_ids [Array<BSON::ObjectId>]
|
36
36
|
# Job ids to exclude when looking for the next job
|
37
37
|
def self.rocket_job_retrieve(worker_name, skip_job_ids = nil)
|
38
|
-
run_at
|
38
|
+
run_at = [
|
39
39
|
{run_at: {'$exists' => false}},
|
40
40
|
{run_at: {'$lte' => Time.now}}
|
41
41
|
]
|
42
|
-
query
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
42
|
+
update = query = nil
|
43
|
+
if defined?(RocketJobPro)
|
44
|
+
query = {
|
45
|
+
'$and' => [
|
46
|
+
{
|
47
|
+
'$or' => [
|
48
|
+
{'state' => 'queued'}, # Jobs
|
49
|
+
{'state' => 'running', 'sub_state' => :processing} # Slices
|
50
|
+
]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
'$or' => run_at
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
update = {'$set' => {'worker_name' => worker_name, 'state' => 'running'}}
|
58
|
+
else
|
59
|
+
query = {'state' => 'queued', '$or' => run_at}
|
60
|
+
update = {'$set' => {'worker_name' => worker_name, 'state' => 'running', 'started_at' => Time.now}}
|
61
|
+
end
|
63
62
|
|
64
63
|
query['_id'] = {'$nin' => skip_job_ids} if skip_job_ids && skip_job_ids.size > 0
|
65
64
|
|
66
65
|
if doc = find_and_modify(
|
67
66
|
query: query,
|
68
67
|
sort: {priority: 1, _id: 1},
|
69
|
-
update:
|
68
|
+
update: update
|
70
69
|
)
|
71
70
|
load(doc)
|
72
71
|
end
|
@@ -59,7 +59,9 @@ module RocketJob
|
|
59
59
|
logger.info "Destroyed expired job #{job.class.name}, id:#{job.id}"
|
60
60
|
else
|
61
61
|
job.worker_name = worker_name
|
62
|
-
job.rocket_job_fail_on_exception!(worker_name)
|
62
|
+
job.rocket_job_fail_on_exception!(worker_name) do
|
63
|
+
defined?(RocketJobPro) ? job.start! : job.start
|
64
|
+
end
|
63
65
|
return job if job.running?
|
64
66
|
end
|
65
67
|
end
|
data/lib/rocket_job/version.rb
CHANGED
data/lib/rocket_job/worker.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require 'socket'
|
3
2
|
require 'concurrent'
|
4
3
|
module RocketJob
|
5
4
|
# Worker
|
@@ -33,11 +32,10 @@ module RocketJob
|
|
33
32
|
|
34
33
|
# @formatter:off
|
35
34
|
# Unique Name of this worker instance
|
36
|
-
#
|
37
|
-
# are started on the same host
|
35
|
+
# Default: `host name:PID`
|
38
36
|
# The unique name is used on re-start to re-queue any jobs that were being processed
|
39
37
|
# at the time the worker or host unexpectedly terminated, if any
|
40
|
-
key :name, String, default: -> { "#{
|
38
|
+
key :name, String, default: -> { "#{SemanticLogger.host}:#{$$}" }
|
41
39
|
|
42
40
|
# The maximum number of threads that this worker should use
|
43
41
|
# If set, it will override the default value in RocketJob::Config
|
data/test/test_helper.rb
CHANGED
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: 2.0.0.
|
4
|
+
version: 2.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mongo_ha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|