Skip to content

Commit

Permalink
Fix the healthcheck
Browse files Browse the repository at this point in the history
Currently we update the health check file on end of process messages
instead now we update the health check file after processing each queue
  • Loading branch information
rohandev committed Aug 20, 2020
1 parent e9e3295 commit 838d348
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions eb_sqs/worker/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ def process_queues(self, queue_names):
static_queues = queues
last_update_time = timezone.now() - timedelta(seconds=settings.REFRESH_PREFIX_QUEUES_S)

self.write_healthcheck_file()
last_healthcheck_time = timezone.now()

logger.debug('[django-eb-sqs] Connected to SQS: {}'.format(', '.join(queue_names)))

worker = WorkerFactory.default().create()
Expand Down Expand Up @@ -75,11 +72,11 @@ def process_queues(self, queue_names):
else:
self.process_messages(queues, worker, static_queues)

if timezone.now() - timedelta(seconds=settings.MIN_HEALTHCHECK_WRITE_PERIOD_S) > last_healthcheck_time:
self.write_healthcheck_file()
last_healthcheck_time = timezone.now()

def process_messages(self, queues, worker, static_queues):

self.write_healthcheck_file()
last_healthcheck_time = timezone.now()

# type: (list, Worker, list) -> None
for queue in queues:
try:
Expand All @@ -101,6 +98,10 @@ def process_messages(self, queues, worker, static_queues):
self.delete_messages(queue, msg_entries)

self._send_signal(MESSAGES_DELETED, messages=messages)

if timezone.now() - timedelta(seconds=settings.MIN_HEALTHCHECK_WRITE_PERIOD_S) > last_healthcheck_time:
self.write_healthcheck_file()
last_healthcheck_time = timezone.now()
except ClientError as exc:
error_code = exc.response.get('Error', {}).get('Code', None)
if error_code == 'AWS.SimpleQueueService.NonExistentQueue' and queue not in static_queues:
Expand Down

0 comments on commit 838d348

Please sign in to comment.