@@ -103,61 +103,14 @@ call_web_app() {
103103 exit 1
104104 fi
105105
106- # Get the Docker container name (with retries, as the container may take time to start after deployment)
106+ # Get the Docker container name
107107 echo " Finding container name with prefix [ls-$web_app_name ]..."
108- MAX_RETRIES=18
109- RETRY_INTERVAL=10
110- container_name=" "
111- for (( attempt= 1 ; attempt<= MAX_RETRIES; attempt++ )) ; do
112- container_name=$( get_docker_container_name_by_prefix " ls-$web_app_name " ) && break
113- container_name=" "
114-
115- # Print full diagnostics on first, every 6th, and last attempt
116- if [ " $attempt " -eq 1 ] || [ " $(( attempt % 6 )) " -eq 0 ] || [ " $attempt " -eq " $MAX_RETRIES " ]; then
117- echo " === DEBUG (attempt $attempt /$MAX_RETRIES ): Container diagnostics ==="
118-
119- echo " --- All running containers ---"
120- docker ps --format " table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1
121-
122- echo " --- All containers (including stopped/exited) ---"
123- docker ps -a --format " table {{.Names}}\t{{.Image}}\t{{.Status}}" 2>&1
124-
125- echo " --- Docker images ---"
126- docker images --format " table {{.Repository}}\t{{.Tag}}\t{{.ID}}" 2>&1
127-
128- # Check LocalStack logs for web app container creation errors
129- LS_CONTAINER=$( docker ps --format " {{.Names}}" | grep -i " localstack" | head -1)
130- if [ -n " $LS_CONTAINER " ]; then
131- echo " --- LocalStack logs (last 50 lines, filtered for webapp/container/error) ---"
132- docker logs " $LS_CONTAINER " --tail 200 2>&1 | grep -iE " (ls-${web_app_name} |webapp.*container|container.*webapp|pip.*install|requirements|cryptography|certificates|import.*error|module.*not.*found|build.*fail|error.*build|startup|gunicorn|flask)" | tail -50 || echo " (no matching log lines)"
133-
134- echo " --- LocalStack logs (last 30 lines, unfiltered) ---"
135- docker logs " $LS_CONTAINER " --tail 30 2>&1
136- fi
137-
138- # Show logs from any exited containers
139- EXITED=$( docker ps -a --filter " status=exited" --format " {{.Names}}" 2> /dev/null)
140- if [ -n " $EXITED " ]; then
141- echo " --- Exited container logs ---"
142- echo " $EXITED " | while read -r c; do
143- echo " [$c ] logs (last 20 lines):"
144- docker logs " $c " --tail 20 2>&1 | sed ' s/^/ /'
145- done
146- fi
147-
148- echo " === END DEBUG ==="
149- fi
150-
151- if [ " $attempt " -lt " $MAX_RETRIES " ]; then
152- echo " Attempt $attempt /$MAX_RETRIES : Container not found yet. Waiting ${RETRY_INTERVAL} s..."
153- sleep " $RETRY_INTERVAL "
154- fi
155- done
108+ container_name=$( get_docker_container_name_by_prefix " ls-$web_app_name " )
156109
157- if [ -n " $container_name " ]; then
110+ if [ $? -eq 0 ] && [ -n " $container_name " ]; then
158111 echo " Container [$container_name ] found successfully"
159112 else
160- echo " Failed to get container name after $MAX_RETRIES attempts "
113+ echo " Failed to get container name"
161114 exit 1
162115 fi
163116
0 commit comments