sqsrun 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/lib/sqsrun/command/sqsrun.rb +16 -6
- data/lib/sqsrun/version.rb +1 -1
- data/lib/sqsrun/worker.rb +5 -0
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -28,10 +28,12 @@ A Generics Worker Executor Service for Amazon SQS. It polls SQS queue and run co
|
|
28
28
|
--configure PATH.yaml Write configuration file
|
29
29
|
--exec COMMAND Execute command
|
30
30
|
--run SCRIPT.rb Run method named 'run' defined in the script
|
31
|
+
--env K=V Set environment variable
|
31
32
|
-e, --extend-timeout SEC Threashold time before extending visibility timeout (default: timeout * 3/4)
|
32
|
-
-x, --kill-timeout SEC Threashold time before killing process (default: timeout *
|
33
|
+
-x, --kill-timeout SEC Threashold time before killing process (default: timeout * 10)
|
33
34
|
-X, --kill-retry SEC Threashold time before retrying killing process (default: 60)
|
34
35
|
-i, --interval SEC Polling interval (default: 1)
|
36
|
+
-U, --release-on-fail Releases lock if task failed so that other node can retry immediately
|
35
37
|
-d, --daemon PIDFILE Daemonize (default: foreground)
|
36
38
|
-f, --file PATH.yaml Read configuration file
|
37
39
|
|
@@ -74,6 +74,11 @@ op.on('--run SCRIPT.rb', 'Run method named \'run\' defined in the script') {|s|
|
|
74
74
|
conf[:run] = s
|
75
75
|
}
|
76
76
|
|
77
|
+
op.on('--env K=V', 'Set environment variable') {|s|
|
78
|
+
k, v = s.split('=',2)
|
79
|
+
(conf[:env] ||= {})[k] = v
|
80
|
+
}
|
81
|
+
|
77
82
|
op.on('-e', '--extend-timeout SEC', 'Threashold time before extending visibility timeout (default: timeout * 3/4)', Integer) {|i|
|
78
83
|
conf[:extend_timeout] = i
|
79
84
|
}
|
@@ -90,7 +95,7 @@ op.on('-i', '--interval SEC', 'Polling interval (default: 1)', Integer) {|i|
|
|
90
95
|
conf[:interval] = i
|
91
96
|
}
|
92
97
|
|
93
|
-
op.on('-
|
98
|
+
op.on('-U', '--release-on-fail', 'Releases lock if task failed so that other node can retry immediately', TrueClass) {|b|
|
94
99
|
conf[:release_on_fail] = b
|
95
100
|
}
|
96
101
|
|
@@ -99,7 +104,7 @@ op.on('-d', '--daemon PIDFILE', 'Daemonize (default: foreground)') {|s|
|
|
99
104
|
}
|
100
105
|
|
101
106
|
op.on('-f', '--file PATH.yaml', 'Read configuration file') {|s|
|
102
|
-
conf[:
|
107
|
+
(conf[:files] ||= []) << s
|
103
108
|
}
|
104
109
|
|
105
110
|
|
@@ -125,11 +130,16 @@ begin
|
|
125
130
|
usage nil
|
126
131
|
end
|
127
132
|
|
128
|
-
if conf[:
|
133
|
+
if conf[:files]
|
129
134
|
require 'yaml'
|
130
|
-
|
135
|
+
docs = ''
|
136
|
+
conf[:files].each {|file|
|
137
|
+
docs << File.read(file)
|
138
|
+
}
|
131
139
|
y = {}
|
132
|
-
|
140
|
+
YAML.load_documents(docs) {|yaml|
|
141
|
+
yaml.each_pair {|k,v| y[k.to_sym] = v }
|
142
|
+
}
|
133
143
|
|
134
144
|
conf = defaults.merge(y).merge(conf)
|
135
145
|
|
@@ -179,7 +189,7 @@ end
|
|
179
189
|
if confout
|
180
190
|
require 'yaml'
|
181
191
|
|
182
|
-
conf.delete(:
|
192
|
+
conf.delete(:files)
|
183
193
|
conf[:args] = ARGV
|
184
194
|
|
185
195
|
y = {}
|
data/lib/sqsrun/version.rb
CHANGED
data/lib/sqsrun/worker.rb
CHANGED
@@ -15,6 +15,7 @@ class Worker
|
|
15
15
|
@kill_retry = conf[:kill_retry]
|
16
16
|
@interval = conf[:interval]
|
17
17
|
@release_on_fail = conf[:release_on_fail]
|
18
|
+
@env = conf[:env] || {}
|
18
19
|
@finished = false
|
19
20
|
|
20
21
|
@extender = TimerThread.new(@visibility_timeout, @extend_timeout, @kill_timeout, @kill_retry)
|
@@ -80,6 +81,10 @@ class Worker
|
|
80
81
|
def process(msg)
|
81
82
|
puts "started id=#{msg.id}"
|
82
83
|
|
84
|
+
@env.each_pair {|k,v|
|
85
|
+
ENV[k] = v
|
86
|
+
}
|
87
|
+
|
83
88
|
@extender.set_message(msg)
|
84
89
|
|
85
90
|
success = false
|
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: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sadayuki Furuhashi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-23 00:00:00 +09:00
|
19
19
|
default_executable: sqsrun
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +90,7 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 1.3.7
|
91
91
|
signing_key:
|
92
92
|
specification_version: 3
|
93
|
-
summary: Generic
|
93
|
+
summary: Generic Worker Executor Service for Amazon SQS
|
94
94
|
test_files:
|
95
95
|
- test/exec_test.rb
|
96
96
|
- test/test_helper.rb
|