Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health_check_no.sh script for Docker and non-Docker health checks #3108

Merged
merged 8 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 6 additions & 44 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##############################################################################

Check warning on line 1 in .github/workflows/pull-request.yml

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
##############################################################################
#
# NOTE!
Expand Down Expand Up @@ -340,20 +340,8 @@
echo $! > .pidfile_prod
- name: Check if Production App is running
run: |
timeout=120
echo "Starting production health check with ${timeout}s timeout"
while ! nc -z localhost 4173 && [ $timeout -gt 0 ]; do
sleep 1
timeout=$((timeout-1))
if [ $((timeout % 10)) -eq 0 ]; then
echo "Still waiting for production app to start... ${timeout}s remaining"
fi
done
if [ $timeout -eq 0 ]; then
echo "Timeout waiting for production application to start"
exit 1
fi
echo "Production app started successfully"
chmod +x .github/workflows/scripts/health_check.sh
.github/workflows/scripts/health_check.sh 4321 120
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
- name: Stop Production App
run: |
if [ -f .pidfile_prod ]; then
Expand All @@ -365,20 +353,8 @@
echo $! > .pidfile_dev
- name: Check if Development App is running
run: |
timeout=120
echo "Starting development health check with ${timeout}s timeout"
while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do
sleep 1
timeout=$((timeout-1))
if [ $((timeout % 10)) -eq 0 ]; then
echo "Still waiting for development app to start... ${timeout}s remaining"
fi
done
if [ $timeout -eq 0 ]; then
echo "Timeout waiting for development application to start"
exit 1
fi
echo "Development app started successfully"
chmod +x .github/workflows/scripts/health_check_no.sh
.github/workflows/scripts/health_check_no.sh 4321 120
- name: Stop Development App
if: always()
run: |
Expand Down Expand Up @@ -414,22 +390,8 @@
echo "Docker container started successfully"
- name: Check if Talawa Admin App is running
run: |
timeout="${HEALTH_CHECK_TIMEOUT:-120}"
echo "Starting health check with ${timeout}s timeout"
while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do
sleep 1
timeout=$((timeout-1))
if [ $((timeout % 10)) -eq 0 ]; then
echo "Still waiting for app to start... ${timeout}s remaining"
fi
done
if [ $timeout -eq 0 ]; then
echo "Timeout waiting for application to start"
echo "Container logs:"
docker logs talawa-admin-app-container
exit 1
fi
echo "Port check passed, verifying health endpoint..."
chmod +x .github/workflows/scripts/health_check.sh
.github/workflows/scripts/health_check.sh 4321 120 true
- name: Stop Docker Container
if: always()
run: |
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/scripts/health_check_no.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .github/workflows/scripts/health_check.sh

Check warning on line 1 in .github/workflows/scripts/health_check_no.sh

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
#!/bin/bash
im-vedant marked this conversation as resolved.
Show resolved Hide resolved

port="$1"
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
timeout="${2:-120}"
is_docker_test="${3:-false}"
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
echo "Starting health check with ${timeout}s timeout"
while ! nc -z localhost "${port}" && [ "${timeout}" -gt 0 ]; do
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
sleep 1
timeout=$((timeout-1))
if [ $((timeout % 10)) -eq 0 ]; then
echo "Still waiting for app to start... ${timeout}s remaining"
fi
done
im-vedant marked this conversation as resolved.
Show resolved Hide resolved

if [ "${timeout}" -eq 0 ]; then
echo "Timeout waiting for application to start"
if [ "${is_docker_test}" = "true" ]; then
echo "Fetching Docker container logs..."
docker logs talawa-admin-app-container
fi
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi
echo "App started successfully on port ${port}"
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
im-vedant marked this conversation as resolved.
Show resolved Hide resolved
Loading