jflow 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/jflow_worker +26 -1
- data/lib/jflow/activity/task.rb +2 -1
- data/lib/jflow/activity/worker.rb +20 -6
- data/lib/jflow/version.rb +1 -1
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 308f589a87738e9ab38d7a714ade494978ae753e
|
4
|
+
data.tar.gz: 7b4769dcd0ffe32e4faa9983f23cb8a0efe693ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0223780c90d2a666ab88fa98663ee704031d09ffe8c55e9f1a56206f6763c5d583e984b8d5da1384b7e04fdcef3a37dcaaad823402a928d16aab3889b444392
|
7
|
+
data.tar.gz: 83afde68c71aca64663dd9dd5d2e769b50465a44cdd55ea099f3579d705a3959d0ba9b0cdc9a98af653c2c1d117328d55583de0131b92f3f842152d7534740b4
|
data/bin/jflow_worker
CHANGED
@@ -38,6 +38,31 @@ configuration["number_of_workers"].times do |i|
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
threads
|
41
|
+
def shutdown(threads)
|
42
|
+
JFlow.configuration.logger.info "Sending kill signal to running threads. Please wait for current polling to finish"
|
43
|
+
kill_threads = []
|
44
|
+
threads.each do |thread|
|
45
|
+
thread["do_exit"] = true
|
46
|
+
if thread["state"] == :working
|
47
|
+
kill_threads << Thread.new do
|
48
|
+
sleep 60
|
49
|
+
if thread.alive?
|
50
|
+
thread.raise("Workers are going down!")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
kill_threads.each { |thr| thr.join }
|
56
|
+
end
|
57
|
+
|
58
|
+
Signal.trap("INT") {
|
59
|
+
shutdown(threads)
|
60
|
+
}
|
61
|
+
|
62
|
+
# Trap `Kill `
|
63
|
+
Signal.trap("TERM") {
|
64
|
+
shutdown(threads)
|
65
|
+
}
|
42
66
|
|
67
|
+
threads.each { |thr| thr.join }
|
43
68
|
|
data/lib/jflow/activity/task.rb
CHANGED
@@ -40,6 +40,7 @@ module JFlow
|
|
40
40
|
|
41
41
|
def run!
|
42
42
|
log "Started #{klass}##{method} with #{input}"
|
43
|
+
|
43
44
|
result = klass.new.send(method, *input) || "done"
|
44
45
|
log "Result is #{result.class} #{result}"
|
45
46
|
completed!(result)
|
@@ -57,7 +58,7 @@ module JFlow
|
|
57
58
|
swf_client.respond_activity_task_failed({
|
58
59
|
task_token: token,
|
59
60
|
reason: exception.message,
|
60
|
-
details: exception.backtrace.join("\n"),
|
61
|
+
details: exception.backtrace ? exception.backtrace.join("\n") : "no stacktrace",
|
61
62
|
})
|
62
63
|
end
|
63
64
|
|
@@ -10,33 +10,43 @@ module JFlow
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def start!
|
13
|
-
|
13
|
+
while should_be_working?
|
14
14
|
log "Polling for task on #{domain} - #{tasklist}"
|
15
15
|
poll
|
16
16
|
end
|
17
|
+
log "Thread is marked as exiting, stopping the poll"
|
17
18
|
end
|
18
19
|
|
19
|
-
private
|
20
20
|
|
21
21
|
def poll
|
22
|
+
Thread.current["state"] = :polling
|
22
23
|
response = JFlow.configuration.swf_client.poll_for_activity_task(poll_params)
|
23
24
|
if response.task_token
|
24
|
-
|
25
|
+
log "Got task #{response.task_token}"
|
26
|
+
task = JFlow::Activity::Task.new(response)
|
27
|
+
if should_be_working?
|
28
|
+
process(task)
|
29
|
+
else
|
30
|
+
#The worker is shuting down, we don't want to start working on anything
|
31
|
+
#so we fail the task and let the decider queue it up for retry later
|
32
|
+
task.failed!(Exception.new("Worker is going down!"))
|
33
|
+
end
|
25
34
|
else
|
26
35
|
log "Got no task"
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
30
|
-
def
|
31
|
-
log "Got task #{response.task_token}"
|
32
|
-
task = JFlow::Activity::Task.new(response)
|
39
|
+
def process(task)
|
33
40
|
begin
|
41
|
+
Thread.current["state"] = :working
|
34
42
|
task.run!
|
35
43
|
rescue => exception
|
36
44
|
task.failed!(exception)
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
48
|
+
private
|
49
|
+
|
40
50
|
def identity
|
41
51
|
@identity ||= "#{`hostname`.chomp}-#{Thread.current.object_id}"
|
42
52
|
end
|
@@ -55,6 +65,10 @@ module JFlow
|
|
55
65
|
}
|
56
66
|
end
|
57
67
|
|
68
|
+
def should_be_working?
|
69
|
+
Thread.current["do_exit"] != true
|
70
|
+
end
|
71
|
+
|
58
72
|
end
|
59
73
|
end
|
60
74
|
end
|
data/lib/jflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Verbinnen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4'
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - ~>
|
22
|
+
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '4'
|
25
25
|
prerelease: false
|
@@ -28,12 +28,12 @@ dependencies:
|
|
28
28
|
name: aws-sdk
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2'
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- - ~>
|
36
|
+
- - "~>"
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '2'
|
39
39
|
prerelease: false
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
name: hash_validator
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.4'
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - ~>
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0.4'
|
53
53
|
prerelease: false
|
@@ -56,12 +56,12 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.10'
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ~>
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '1.10'
|
67
67
|
prerelease: false
|
@@ -70,12 +70,12 @@ dependencies:
|
|
70
70
|
name: rake
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '10.0'
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - ~>
|
78
|
+
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '10.0'
|
81
81
|
prerelease: false
|
@@ -84,12 +84,12 @@ dependencies:
|
|
84
84
|
name: rspec
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
prerelease: false
|
@@ -98,12 +98,12 @@ dependencies:
|
|
98
98
|
name: simplecov
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
prerelease: false
|
@@ -118,9 +118,9 @@ executables:
|
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
|
-
- .gitignore
|
122
|
-
- .rspec
|
123
|
-
- .travis.yml
|
121
|
+
- ".gitignore"
|
122
|
+
- ".rspec"
|
123
|
+
- ".travis.yml"
|
124
124
|
- Gemfile
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
@@ -146,17 +146,17 @@ require_paths:
|
|
146
146
|
- lib
|
147
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- -
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
153
|
requirements:
|
154
|
-
- -
|
154
|
+
- - ">="
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.4.
|
159
|
+
rubygems_version: 2.4.8
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: SWF Flow framework for jRuby
|