-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiagnose.sh
28 lines (22 loc) · 844 Bytes
/
diagnose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Fetch Docker logs for the Flask container
echo "Fetching Docker logs for the Flask container..."
docker-compose logs app
# Check if the Flask container is running
container_status=$(docker inspect -f '{{.State.Running}}' my_project_app_1)
if [ "$container_status" == "true" ]; then
echo "Flask container is running."
else
echo "Flask container is not running. Attempting to restart..."
docker-compose restart app
fi
# Test the Flask server
echo "Testing Flask server..."
http_status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000)
if [ "$http_status" == "200" ]; then
echo "Flask server is responding correctly. HTTP status code: $http_status"
else
echo "Flask server is not responding correctly. HTTP status code: $http_status"
echo "Fetching latest Docker logs..."
docker-compose logs app
fi