herdst_worker 0.2.19 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6654d05e7c9d7f3a3060096bbc9acf651360fb25e3e2527292632518537f61f5
4
- data.tar.gz: 98ce22ba4604f0c889bdfd27d6627ae63c36e45746e5c38697518c6675f993c2
3
+ metadata.gz: 9fa8ccaf7c0b1ea579be583057020ce2499ad6d7fd1ea806f526c81d0a3adfe3
4
+ data.tar.gz: 1c4af6793b81b741e308cad5db603fce45bd81dfb408ece724a4091c1c910471
5
5
  SHA512:
6
- metadata.gz: 6f21d913498e7514c5a9fc591bdfc2fa65054692a0780fd075614824fed061c6eaf383f6e6133132b6674c2dc6ff7ef27215e3c35f877dbf5b0771a739e81613
7
- data.tar.gz: e112479b119fce002f93b26b1a2931f6b1e24294210751446974f63f0b1450d8e50ba1aa8645093244d9d9a66eccd8306a66e59c137dd2ea7dfd89993932e024
6
+ metadata.gz: 7bf2ce6ce4e78f2f8b409c63d390774028e0296afd81dde6664ba962f60089a8ea275d850adfbffd5970145eb499225d4a377df229c250761db40aa592521e24
7
+ data.tar.gz: 42c9f0b24900bef7ede09b10d0200cafa878f24dbd7d8506c4ea69f11555496b1c70bf6b67da800c1c2cc88c5409d5b8a1818e965cb05891fb4bf50b451acecb
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ tmp_path = Dir.pwd + "/tmp"
4
+ process_id = File.new(tmp_path + "/process_id").read.strip rescue nil
5
+ process_status = File.new(tmp_path + "/process_status").read.strip rescue nil
6
+ unhealthy = process_id == nil || ["stopped"].include?(process_status)
7
+
8
+ Kernel.exit(unhealthy ? 1 : 0)
@@ -91,7 +91,7 @@ module HerdstWorker
91
91
 
92
92
 
93
93
  def register_new_task
94
- # TODO
94
+
95
95
  end
96
96
 
97
97
 
@@ -111,7 +111,7 @@ module HerdstWorker
111
111
  })
112
112
 
113
113
  rescue Exception => ex
114
- self.force_stop(30)
114
+ self.stop
115
115
 
116
116
  end
117
117
  end
@@ -123,8 +123,9 @@ module HerdstWorker
123
123
  self.app.deregister_task
124
124
 
125
125
  elsif (self.processor_status == "working") && (current_time >= self.stop_processing_at)
126
+ self.app.force_stop(900)
126
127
  self.app.register_new_task
127
-
128
+
128
129
  set_status "stopping"
129
130
 
130
131
  # On finishing wait for jobs to complete and then set status to idle
@@ -180,50 +181,51 @@ module HerdstWorker
180
181
  self.job_count -= 1
181
182
 
182
183
  }.rescue { |ex|
183
- if will_fail_permanently
184
- self.app.logger.queue.error "Message failed #{attempt_number} times, Reporting and failing permanently. \n#{ex.to_s} \n#{ex.backtrace.join("\n")}"
185
- Sentry.capture_exception(ex, {
186
- :level => "fatal",
187
- :extra => {
188
- "queue_attempts" => attempt_number,
189
- "queue_message_body" => msg.body
190
- }
191
- })
192
-
193
- else
194
- self.app.logger.queue.error "Message failed #{attempt_number} times, Adding back to queue."
195
-
196
- if self.app.config.is_dev?
197
- puts ex.inspect
198
- puts ex.backtrace
199
- end
200
-
201
- replaced_message = {
202
- :queue_url => self.poller.queue_url,
203
- :message_body => msg.body,
204
- :delay_seconds => self.visibility_timeout,
205
- :message_attributes => msg_attrs.merge({
206
- "attempts" => {
207
- :string_value => attempt_number.to_s,
208
- :data_type => "Number"
184
+ begin
185
+ if will_fail_permanently
186
+ self.app.logger.queue.error "Message failed #{attempt_number} times, Reporting and failing permanently. \n#{ex.to_s} \n#{ex.backtrace.join("\n")}"
187
+ Sentry.capture_exception(ex, {
188
+ :level => "fatal",
189
+ :extra => {
190
+ "queue_attempts" => attempt_number,
191
+ "queue_message_body" => msg.body
209
192
  }
210
193
  })
211
- }
194
+
195
+ else
196
+ self.app.logger.queue.error "Message failed #{attempt_number} times, Adding back to queue."
197
+
198
+ self.poller.client.send_message({
199
+ :queue_url => self.poller.queue_url,
200
+ :message_body => msg.body,
201
+ :delay_seconds => self.visibility_timeout,
202
+ :message_attributes => msg_attrs.merge({
203
+ "attempts" => {
204
+ :string_value => attempt_number.to_s,
205
+ :data_type => "Number"
206
+ }
207
+ })
208
+ })
209
+ end
212
210
 
213
- self.poller.client.send_message replaced_message
214
- end
215
-
216
- if self.app.config.is_dev?
217
- self.app.logger.queue.error "Processor Error:"
218
- self.app.logger.queue.error ex.message
219
- self.app.logger.queue.error ex.backtrace
211
+ if self.app.config.is_dev?
212
+ self.app.logger.queue.error "Processor Error:"
213
+ self.app.logger.queue.error ex.message
214
+ self.app.logger.queue.error ex.backtrace
215
+ end
216
+
217
+ rescue Exception => inner_ex
218
+ self.app.logger.queue.error inner_ex.message
219
+
220
+ ensure
221
+ self.job_count -= 1
222
+
220
223
  end
221
-
222
- self.job_count -= 1
223
224
  }.execute
224
225
  else
225
226
  self.poller.change_message_visibility_timeout(msg, 5)
226
227
  throw :skip_delete
228
+
227
229
  end
228
230
  end
229
231
 
@@ -1,3 +1,3 @@
1
1
  module HerdstWorker
2
- VERSION = '0.2.19'
2
+ VERSION = '0.2.21'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herdst_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.19
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herd.St
@@ -240,6 +240,7 @@ email:
240
240
  executables:
241
241
  - herdst_worker
242
242
  - herdst_worker_console
243
+ - herdst_worker_health
243
244
  extensions: []
244
245
  extra_rdoc_files: []
245
246
  files:
@@ -247,6 +248,7 @@ files:
247
248
  - ReadMe.md
248
249
  - bin/herdst_worker
249
250
  - bin/herdst_worker_console
251
+ - bin/herdst_worker_health
250
252
  - lib/herdst_worker.rb
251
253
  - lib/herdst_worker/adapters/database.rb
252
254
  - lib/herdst_worker/adapters/facade.rb