Skip to content

Commit

Permalink
added script to check unhealthy containers
Browse files Browse the repository at this point in the history
added script to check unhealthy containers
  • Loading branch information
tatanithin committed Jan 14, 2025
1 parent ada7496 commit 5229727
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nested-labvm/services/atdStartup/atdStartup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,6 @@ then
done
bash /opt/ceos/scripts/Startup.sh
fi
echo "Executing script to check unhealthy containers"
rsync -av /opt/atd/nested-labvm/services/atdStartup/unhealthyContainers.sh /usr/local/bin/
bash /usr/local/bin/unhealthyContainers.sh
23 changes: 23 additions & 0 deletions nested-labvm/services/atdStartup/unhealthyContainers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

MAX_RETRIES=5
RETRY_DELAY=10
CODER_CONTAINER="atd-coder"

for attempt in $(seq 1 $MAX_RETRIES); do
echo "Attempt $attempt of $MAX_RETRIES"
if ! sudo docker ps | grep -q "$CODER_CONTAINER"; then
echo "Coder container failed to start. Retrying..."
else
echo "Coder container is running."
break
fi
sleep $RETRY_DELAY

if [ $attempt -eq $MAX_RETRIES ]; then
echo "Coder container failed to start after $MAX_RETRIES attempts. Pruning all containers."
sudo docker container prune -f
sudo bash /usr/local/bin/atdUpdate.sh
break
fi
done

0 comments on commit 5229727

Please sign in to comment.