Skip to content

Commit

Permalink
Change to 30 seconds unhealthy adn db fix restart config
Browse files Browse the repository at this point in the history
  • Loading branch information
r4ulcl committed Dec 6, 2024
1 parent 1194fb3 commit 9fbcc0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:

db:
image: postgres:14
restart: on-failure # Automatically restart on failure
restart: unless-stopped
#env_file: ./nzyme/.env
env_file: .env
container_name: WiFiChallengeLab-nzyme-db
Expand Down
14 changes: 8 additions & 6 deletions vagrant/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,17 @@ cat << 'EOF' > $SCRIPT_PATH
# Loop to constantly monitor containers' health
while true; do
# Check all containers with an "unhealthy" status
for container in $(docker ps --filter "health=unhealthy" --format "{{.Names}}"); do
# Log the unhealthy container being restarted
echo "$(date) - Restarting unhealthy container: $container"
docker restart "$container"
# Wait 30 seconds and check again if the container is still unhealthy
sleep 30
if docker ps --filter "health=unhealthy" --filter "name=$container" --format "{{.Names}}" | grep -q "$container"; then
echo "$(date) - Restarting unhealthy container: $container"
docker restart "$container"
fi
done
# Sleep for a few seconds before checking again
sleep 10
# Sleep before checking again
sleep 30
done
EOF

Expand Down

0 comments on commit 9fbcc0b

Please sign in to comment.