Skip to content

Commit

Permalink
Bug fix on task starting too fast and failing to reach the log group …
Browse files Browse the repository at this point in the history
…causing script to error
  • Loading branch information
adenot committed May 13, 2020
1 parent 55057e6 commit 26d6047
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/run-task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ TASK_ID=$(aws ecs run-task \
--query="tasks[0].taskArn" \
--output=text)

# sleep 5
sleep 5

while [ "$(aws ecs describe-tasks --tasks $TASK_ID --cluster $CLUSTER_NAME --query="tasks[0].lastStatus" --output=text)" == "PENDING" ]
do
sleep 1
done

TASK_STATUS=$(aws ecs describe-tasks \
--tasks $TASK_ID \
--cluster $CLUSTER_NAME \
--query="tasks[0].lastStatus" \
--output=text)
echo "---> Task ID $TASK_ID"
echo "---> Task Status $TASK_STATUS"

./tail-task-logs.py $TASK_ID

Expand Down
3 changes: 2 additions & 1 deletion src/tail-task-logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
print("Stop Code: %s" % response['tasks'][0]['stopCode'])
print("")
break
time.sleep(1)
else:
extra_args['nextToken'] = log_stream_events['nextForwardToken']

time.sleep(1)

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

0 comments on commit 26d6047

Please sign in to comment.