Skip to content

Commit

Permalink
cleaned SQS message, added kill
Browse files Browse the repository at this point in the history
  • Loading branch information
kreynoldsf5 committed Apr 10, 2024
1 parent fc00547 commit 3b0d197
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
10 changes: 7 additions & 3 deletions base/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import json
import re
import atexit
import requests
import boto3

Expand Down Expand Up @@ -94,7 +95,7 @@ def query_metadata(metadata_base_url: str) -> dict|None:
print(f"Error extracting metadata: {e}")
return None

def send_sqs(metadata: dict) -> dict|None:
def send_sqs(metadata: dict, kill: bool=False) -> dict|None:
"""
Send payload to SQS
"""
Expand All @@ -106,9 +107,10 @@ def send_sqs(metadata: dict) -> dict|None:
aws_secret_access_key=metadata['awsSecret']
)
message = {
'depID': metadata['depID'],
'id': metadata['depID'],
'deployer': metadata['deployer'],
'labID': metadata['labID'],
'lab_id': metadata['labID'],
'kill': kill
}
except Exception as e:
print(f"Error building SQS client and message: {e}")
Expand All @@ -134,6 +136,8 @@ def main():
max_retries = 6
retries = 0

atexit.register(send_sqs(metadata, True))

while retries < max_retries:
success = send_sqs(metadata)
if success:
Expand Down

0 comments on commit 3b0d197

Please sign in to comment.