Skip to content

Commit

Permalink
Merge pull request #5 from DNXLabs/add_db_migration
Browse files Browse the repository at this point in the history
removing extra fields
  • Loading branch information
helderklemp authored Feb 16, 2020
2 parents 6f18aaa + 20b70d4 commit f2a33ca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tail-task-logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
cluster_name=os.environ['CLUSTER_NAME']
app_name=os.environ['APP_NAME']
task_arn=os.environ['TASK_ID']
app_command=os.environ['DEFAULT_COMMAND']
task_number=task_arn.split(":task/",1)[1] #get the task number id
last_event = None

Expand All @@ -16,18 +15,20 @@
response = aws_ecs.describe_tasks(
cluster=cluster_name,
tasks=[task_arn])

logs = boto3.client('logs')
task_status = response['tasks'][0]['lastStatus']
events_collected = []
print('Task status', task_status)
logGroupName='/ecs/'+cluster_name+'/'+app_name
print('Searching logs for ', logGroupName)
time.sleep(4)
time.sleep(5)

logStreams = logs.describe_log_streams(
logGroupName=logGroupName,
logStreamNamePrefix=app_name+'/'+app_command+'/'+app_name+'/'+task_number,
logStreamNamePrefix=app_name+'/'+app_name+'/'+task_number,
limit=1,
descending=True)

for stream in logStreams['logStreams']:
streamName=stream['logStreamName']
print('log Streams', streamName)
Expand All @@ -39,7 +40,7 @@
print(log['message'])
if task_status == 'STOPPED':
break
time.sleep(10)
time.sleep(5)

except Exception as e:
print("error: " + str(e))
Expand Down

0 comments on commit f2a33ca

Please sign in to comment.