sqsrun 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/lib/sqsrun/command/sqsrun.rb +7 -2
- data/lib/sqsrun/version.rb +1 -1
- data/lib/sqsrun/worker.rb +6 -3
- metadata +3 -3
data/ChangeLog
CHANGED
@@ -15,6 +15,7 @@ defaults = {
|
|
15
15
|
:timeout => 30,
|
16
16
|
:interval => 1,
|
17
17
|
:kill_retry => 60,
|
18
|
+
:release_on_fail => false,
|
18
19
|
}
|
19
20
|
|
20
21
|
conf = { }
|
@@ -77,7 +78,7 @@ op.on('-e', '--extend-timeout SEC', 'Threashold time before extending visibility
|
|
77
78
|
conf[:extend_timeout] = i
|
78
79
|
}
|
79
80
|
|
80
|
-
op.on('-x', '--kill-timeout SEC', 'Threashold time before killing process (default: timeout *
|
81
|
+
op.on('-x', '--kill-timeout SEC', 'Threashold time before killing process (default: timeout * 10)', Integer) {|i|
|
81
82
|
conf[:kill_timeout] = i
|
82
83
|
}
|
83
84
|
|
@@ -89,6 +90,10 @@ op.on('-i', '--interval SEC', 'Polling interval (default: 1)', Integer) {|i|
|
|
89
90
|
conf[:interval] = i
|
90
91
|
}
|
91
92
|
|
93
|
+
op.on('-E', '--release-on-fail', 'Releases lock if task failed so that other node can retry immediately', TrueClass) {|b|
|
94
|
+
conf[:release_on_fail] = b
|
95
|
+
}
|
96
|
+
|
92
97
|
op.on('-d', '--daemon PIDFILE', 'Daemonize (default: foreground)') {|s|
|
93
98
|
conf[:daemon] = s
|
94
99
|
}
|
@@ -159,7 +164,7 @@ begin
|
|
159
164
|
end
|
160
165
|
|
161
166
|
unless conf[:kill_timeout]
|
162
|
-
conf[:kill_timeout] = conf[:timeout] *
|
167
|
+
conf[:kill_timeout] = conf[:timeout] * 10
|
163
168
|
end
|
164
169
|
|
165
170
|
if !conf[:queue] && (type != :list && type != :conf)
|
data/lib/sqsrun/version.rb
CHANGED
data/lib/sqsrun/worker.rb
CHANGED
@@ -14,6 +14,7 @@ class Worker
|
|
14
14
|
@kill_timeout = conf[:kill_timeout]
|
15
15
|
@kill_retry = conf[:kill_retry]
|
16
16
|
@interval = conf[:interval]
|
17
|
+
@release_on_fail = conf[:release_on_fail]
|
17
18
|
@finished = false
|
18
19
|
|
19
20
|
@extender = TimerThread.new(@visibility_timeout, @extend_timeout, @kill_timeout, @kill_retry)
|
@@ -78,13 +79,13 @@ class Worker
|
|
78
79
|
|
79
80
|
def process(msg)
|
80
81
|
puts "started id=#{msg.id}"
|
81
|
-
thread = Thread.new(msg.to_s, &@run_proc.method(:call))
|
82
82
|
|
83
83
|
@extender.set_message(msg)
|
84
84
|
|
85
85
|
success = false
|
86
86
|
begin
|
87
|
-
|
87
|
+
@run_proc.call(msg.to_s)
|
88
|
+
puts "finished id=#{msg.id}"
|
88
89
|
success = true
|
89
90
|
rescue
|
90
91
|
puts "failed id=#{msg.id}: #{$!}"
|
@@ -98,7 +99,9 @@ class Worker
|
|
98
99
|
if success
|
99
100
|
msg.delete
|
100
101
|
else
|
101
|
-
|
102
|
+
if @release_on_fail
|
103
|
+
msg.visibility = 0
|
104
|
+
end
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqsrun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sadayuki Furuhashi
|