From 492ddc1de9f66edc2f0c87244cb3d6d76b807d1f Mon Sep 17 00:00:00 2001 From: Geeth Sandaru Madhushan Date: Mon, 16 Dec 2024 18:26:23 +0530 Subject: [PATCH] Updates dev_ci_cd.yml --- .github/workflows/dev_ci_cd.yml | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev_ci_cd.yml b/.github/workflows/dev_ci_cd.yml index 532f8ee58f..e4a8ed8616 100644 --- a/.github/workflows/dev_ci_cd.yml +++ b/.github/workflows/dev_ci_cd.yml @@ -108,23 +108,26 @@ jobs: ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP " sudo su - appuser echo 'AS_ADMIN_PASSWORD=${{ secrets.PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt - STATUS=\$(/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep 'hmis') - if echo \"$STATUS\" | grep -q 'hmis'; then + if /opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt list-applications | grep -q 'hmis'; then echo 'Application is running.' - rm /tmp/payara-admin-pass.txt else - echo 'Application failed to start.' >&2 - rm /tmp/payara-admin-pass.txt - exit 1 + echo 'Application failed to start.' fi + rm /tmp/payara-admin-pass.txt " - # Verify that the application is reachable via HTTP - RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$SERVER_IP/rh) - if [ "$RESPONSE_CODE" != "200" ]; then - echo "Application is not reachable at http://$SERVER_IP/sethmademo (HTTP $RESPONSE_CODE)" >&2 - exit 1 - fi + # Check if the application is reachable + for i in {1..5}; do + RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$SERVER_IP/rh) + if [ "$RESPONSE_CODE" == "200" ]; then + echo "Application is reachable and healthy." + break + elif [ "$i" == "5" ]; then + echo "Application is not reachable or unhealthy at http://$SERVER_IP/rh (HTTP $RESPONSE_CODE)" + break + fi + sleep 10 + done # Cleanup rm -f private_key.pem