fanforce-workers 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fanforce/workers/version.rb +1 -1
- data/lib/fanforce/workers/workers.rb +19 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTIwODQwZjBlODIxMTMzYmFlNzYzZWY0YzIxMTEzZWRlYjRkYWRmNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDlhMDMyY2Q4YWMzYzgwMmQyYjFiOWFjODBmZWFlYTI2MmYxOWRiMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzIwZmMzMzYyOGVjMWY2NDNjOThjN2NmODk0Mzc5YjEwNjRkZDM4MDkzY2Q4
|
10
|
+
MDVmZmYyMDAwZGYyYmUwZTIyYTQzNjA4YTFiODcwYThhNGNkZmRjN2RhNDkz
|
11
|
+
NzYzOGZlN2QwZTY1MzJkOTBiNGZlMmJhMGYxMjgwMTdiNTEwYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGMxODhiMTRkNDllOTFkZTg5MTYxZWE5NWEwNTQ3NzZiYWY4M2M3YmZkM2E1
|
14
|
+
ZDkxNTdkZTQ5YTRmZDU2ZmM4YjVjNzg0ZTUxNmRlMTAwMzlhYmNhYTZlMmRi
|
15
|
+
YWI4NmZmZWJhZGYyYWQ4MTViNTlkMDRjNDU4Zjc1MmI1N2ViOTA=
|
@@ -106,6 +106,14 @@ class Fanforce::Workers
|
|
106
106
|
@current_retries
|
107
107
|
end
|
108
108
|
|
109
|
+
def self.current_job=(job)
|
110
|
+
@current_job = job
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.current_job
|
114
|
+
@current_job
|
115
|
+
end
|
116
|
+
|
109
117
|
def self.run(worker_data, &code_block)
|
110
118
|
require '.pluginenv'
|
111
119
|
require 'iron_mq'
|
@@ -122,7 +130,9 @@ class Fanforce::Workers
|
|
122
130
|
while (job = queue.get(timeout: 3600)) do
|
123
131
|
puts "JOB #{job_num+=1}: #{job.body}"
|
124
132
|
run_job job, &code_block
|
133
|
+
self.delete_job
|
125
134
|
end
|
135
|
+
self.delete_job
|
126
136
|
puts 'DONE'
|
127
137
|
end
|
128
138
|
|
@@ -135,12 +145,13 @@ class Fanforce::Workers
|
|
135
145
|
print 'PROCESSING MESSAGE: '
|
136
146
|
|
137
147
|
task_data = Fanforce.decode_json(job.body)
|
148
|
+
self.current_job = job
|
138
149
|
self.current_params = task_data[:params]
|
139
150
|
self.current_retries = task_data[:retries]
|
140
151
|
|
141
152
|
set_env_vars(current_worker_env)
|
142
153
|
code_block.call(task_data[:params].clone, retries: task_data[:retries], queue_id: current_queue_id)
|
143
|
-
job
|
154
|
+
self.delete_job(job)
|
144
155
|
|
145
156
|
rescue Exception => e
|
146
157
|
if job.nil?
|
@@ -157,12 +168,18 @@ class Fanforce::Workers
|
|
157
168
|
error[:curl_command] = e.curl_command if e.respond_to?(:curl_command)
|
158
169
|
|
159
170
|
puts "ADDING TO ERROR CACHE: #{error.to_json}"
|
160
|
-
job
|
171
|
+
self.delete_job(job)
|
161
172
|
puts 'DELETED MESSAGE'
|
162
173
|
|
163
174
|
self.add_error current_queue_id, error
|
164
175
|
end
|
165
176
|
|
177
|
+
def self.delete_job(job=nil)
|
178
|
+
return if job.nil? and current_job.nil?
|
179
|
+
(job || current_job).delete
|
180
|
+
self.current_job = nil
|
181
|
+
end
|
182
|
+
|
166
183
|
def self.set_env_vars(vars)
|
167
184
|
vars.each {|k,v| ENV[k.to_s]=v }
|
168
185
|
load 'fanforce/api/ff_globals.rb'
|