Skip to content

Commit

Permalink
fix(cd): add health checking logs
Browse files Browse the repository at this point in the history
  • Loading branch information
astorverse committed Jul 20, 2024
1 parent fbf688f commit 18bae8b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-to-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
ssh -i deploy_key.pem $SERVER "docker run --env-file /home/$ACCOUNT/upload/.env.prod -d -p $NEW_PORT:3000 --name $NEW_SERVICE_NAME -e TZ=Asia/Seoul $ECR_URL/$SERVICE_NAME"
for i in {1..20}; do
echo "Attempting health check on $HOST (attempt $i)"
HEALTH_CHECK=$(ssh -i deploy_key.pem $SERVER "curl -s -o /dev/null -w '%{http_code}' http://localhost:$NEW_PORT/health")
echo "http://localhost:$NEW_PORT/health"
echo "HTTP Status Code: $HEALTH_CHECK"
Expand All @@ -107,7 +108,7 @@ jobs:
echo -e "\n 헬스체크 시도 $i/20 실패. 5초 후 재시도 on $HOST... \n"
sleep 5
done
if [ "$HEALTH_CHECK" -ne 200 ]; then
ssh -i deploy_key.pem $SERVER "docker stop $NEW_SERVICE_NAME && docker rm $NEW_SERVICE_NAME"
exit 1
Expand Down

0 comments on commit 18bae8b

Please sign in to comment.