mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
monolithic alpine container
This commit is contained in:
73
install/alpine-docker/services/healthcheck.sh
Normal file
73
install/alpine-docker/services/healthcheck.sh
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NetAlertX Comprehensive Health Check Script
|
||||
# This script verifies all critical services and endpoints are functioning
|
||||
|
||||
set -e
|
||||
|
||||
EXIT_CODE=0
|
||||
|
||||
echo "[HEALTHCHECK] Starting comprehensive health check..."
|
||||
|
||||
# Function to log errors and set exit code
|
||||
log_error() {
|
||||
echo "[HEALTHCHECK] ERROR: $1" >&2
|
||||
EXIT_CODE=1
|
||||
}
|
||||
|
||||
# Function to log success
|
||||
log_success() {
|
||||
echo "[HEALTHCHECK] ✓ $1"
|
||||
}
|
||||
|
||||
# 1. Check if crond is running
|
||||
if pgrep -f "crond" > /dev/null; then
|
||||
log_success "crond is running"
|
||||
else
|
||||
log_error "crond is not running"
|
||||
fi
|
||||
|
||||
# 2. Check if php-fpm is running
|
||||
if pgrep -f "php-fpm" > /dev/null; then
|
||||
log_success "php-fpm is running"
|
||||
else
|
||||
log_error "php-fpm is not running"
|
||||
fi
|
||||
|
||||
# 3. Check if nginx is running
|
||||
if pgrep -f "nginx" > /dev/null; then
|
||||
log_success "nginx is running"
|
||||
else
|
||||
log_error "nginx is not running"
|
||||
fi
|
||||
|
||||
# 4. Check if python /app/server is running
|
||||
if pgrep -f "python.*server" > /dev/null; then
|
||||
log_success "python /app/server is running"
|
||||
else
|
||||
log_error "python /app/server is not running"
|
||||
fi
|
||||
|
||||
# 5. Check port 20211 is open and contains "netalertx"
|
||||
if curl -sf --max-time 10 "http://localhost:${PORT:-20211}" | grep -i "netalertx" > /dev/null; then
|
||||
log_success "Port ${PORT:-20211} is responding and contains 'netalertx'"
|
||||
else
|
||||
log_error "Port ${PORT:-20211} is not responding or doesn't contain 'netalertx'"
|
||||
fi
|
||||
|
||||
# 6. Check port 20212/graphql returns "graphql" in first lines
|
||||
GRAPHQL_PORT=${GRAPHQL_PORT:-20212}
|
||||
if curl -sf --max-time 10 "http://localhost:${GRAPHQL_PORT}/graphql" | head -10 | grep -i "graphql" > /dev/null; then
|
||||
log_success "Port ${GRAPHQL_PORT}/graphql is responding with GraphQL content"
|
||||
else
|
||||
log_error "Port ${GRAPHQL_PORT}/graphql is not responding or doesn't contain 'graphql'"
|
||||
fi
|
||||
|
||||
# Summary
|
||||
if [ $EXIT_CODE -eq 0 ]; then
|
||||
echo "[HEALTHCHECK] ✅ All health checks passed"
|
||||
else
|
||||
echo "[HEALTHCHECK] ❌ One or more health checks failed"
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
6
install/alpine-docker/services/start-backend.sh
Normal file
6
install/alpine-docker/services/start-backend.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
echo "Starting backend..."
|
||||
cd "${NETALERTX_APP}" || exit
|
||||
export PYTHONPATH="${NETALERTX_SERVER}"
|
||||
# Start the backend, teeing stdout and stderr to log files and the container's console
|
||||
python3 -m server > >(tee /app/log/stdout.log) 2> >(tee /app/log/stderr.log >&2)
|
||||
3
install/alpine-docker/services/start-crond.sh
Normal file
3
install/alpine-docker/services/start-crond.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Starting crond..."
|
||||
exec /usr/sbin/crond -f -L "${LOG_CROND}"
|
||||
5
install/alpine-docker/services/start-nginx.sh
Normal file
5
install/alpine-docker/services/start-nginx.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
echo "Starting nginx..."
|
||||
exec nginx \
|
||||
-c "${NGINX_CONFIG_FILE}" \
|
||||
-g "daemon off;" >> "${LOG_APP_FRONT}" 2>&1
|
||||
3
install/alpine-docker/services/start-php-fpm.sh
Normal file
3
install/alpine-docker/services/start-php-fpm.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Starting php-fpm..."
|
||||
exec /usr/sbin/php-fpm83 -F >> "${LOG_APP_PHP_ERRORS}" 2>&1
|
||||
Reference in New Issue
Block a user