herdst_worker 0.2.20 → 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: 3ce5fcef880ba98bfb395902e833adb341b994af3ad88075578e63e00ee44323
4
- data.tar.gz: b7a9f4fc95c34e96fbcc07efb82ef57ad67744fd645dfe95866685c7ab0ec478
3
+ metadata.gz: 9fa8ccaf7c0b1ea579be583057020ce2499ad6d7fd1ea806f526c81d0a3adfe3
4
+ data.tar.gz: 1c4af6793b81b741e308cad5db603fce45bd81dfb408ece724a4091c1c910471
5
5
  SHA512:
6
- metadata.gz: 73f8e2525c067e07115e0e67b4d55937983a185d98fb682c70f9b3ff7738ee0821602c38c7c786d1ef9b03b3696bb30cd2c234fe5fb8fe0cc8f1ead6fec2b233
7
- data.tar.gz: 3a084a98cd4d0da4cd8bd2e2116585512f358d0fdd8787528e3ebd38a632e8defa240475554d1169c56c8dd5b6800c6f2e578173b41e81d69d969b9bbef19bba
6
+ metadata.gz: 7bf2ce6ce4e78f2f8b409c63d390774028e0296afd81dde6664ba962f60089a8ea275d850adfbffd5970145eb499225d4a377df229c250761db40aa592521e24
7
+ data.tar.gz: 42c9f0b24900bef7ede09b10d0200cafa878f24dbd7d8506c4ea69f11555496b1c70bf6b67da800c1c2cc88c5409d5b8a1818e965cb05891fb4bf50b451acecb
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  tmp_path = Dir.pwd + "/tmp"
4
- process_id = File.new(tmp_path + "/process_id").read rescue nil
5
- process_status = File.new(tmp_path + "/process_status").read rescue nil
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
6
  unhealthy = process_id == nil || ["stopped"].include?(process_status)
7
7
 
8
8
  Kernel.exit(unhealthy ? 1 : 0)
@@ -91,24 +91,7 @@ module HerdstWorker
91
91
 
92
92
 
93
93
  def register_new_task
94
- # info = self.config.metadata.get_service_config
95
- # credentials = self.config.metadata.get_aws_credentials!
96
- # ecs_client = Aws::ECS::Client.new(
97
- # :region => info[:region],
98
- # :credentials => credentials
99
- # )
100
-
101
- # resp = ecs_client.update_service({
102
- # :cluster => info[:cluster],
103
- # :service => info[:service_name],
104
-
105
- # # :task_definition => "amazon-ecs-sample",
106
-
107
- # :desired_count => desired_count,
108
- # })
109
-
110
- # puts "info"
111
- # puts info.inspect
94
+
112
95
  end
113
96
 
114
97
 
@@ -181,50 +181,51 @@ module HerdstWorker
181
181
  self.job_count -= 1
182
182
 
183
183
  }.rescue { |ex|
184
- if will_fail_permanently
185
- self.app.logger.queue.error "Message failed #{attempt_number} times, Reporting and failing permanently. \n#{ex.to_s} \n#{ex.backtrace.join("\n")}"
186
- Sentry.capture_exception(ex, {
187
- :level => "fatal",
188
- :extra => {
189
- "queue_attempts" => attempt_number,
190
- "queue_message_body" => msg.body
191
- }
192
- })
193
-
194
- else
195
- self.app.logger.queue.error "Message failed #{attempt_number} times, Adding back to queue."
196
-
197
- if self.app.config.is_dev?
198
- puts ex.inspect
199
- puts ex.backtrace
200
- end
201
-
202
- replaced_message = {
203
- :queue_url => self.poller.queue_url,
204
- :message_body => msg.body,
205
- :delay_seconds => self.visibility_timeout,
206
- :message_attributes => msg_attrs.merge({
207
- "attempts" => {
208
- :string_value => attempt_number.to_s,
209
- :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
210
192
  }
211
193
  })
212
- }
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
213
210
 
214
- self.poller.client.send_message replaced_message
215
- end
216
-
217
- if self.app.config.is_dev?
218
- self.app.logger.queue.error "Processor Error:"
219
- self.app.logger.queue.error ex.message
220
- 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
+
221
223
  end
222
-
223
- self.job_count -= 1
224
224
  }.execute
225
225
  else
226
226
  self.poller.change_message_visibility_timeout(msg, 5)
227
227
  throw :skip_delete
228
+
228
229
  end
229
230
  end
230
231
 
@@ -1,3 +1,3 @@
1
1
  module HerdstWorker
2
- VERSION = '0.2.20'
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.20
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Herd.St