From 972be70cc2243717462bb3a1324d682120e31be9 Mon Sep 17 00:00:00 2001 From: nutcas3 Date: Fri, 1 May 2026 09:01:20 +0300 Subject: [PATCH] feat: Add API Gateway startup script with health checks and service validation - Add start-gateway.sh script for Traefik-based API Gateway deployment - Add JWT_SECRET environment variable validation with development fallback warning - Create traefik/dynamic directory for dynamic configuration - Add docker-compose orchestration with build and detached mode - Add health check endpoints for Traefik (/ping), API Server (/api/v1/health), and Charging Engine (/v1/health) - Add service URL documentation --- scripts/start-gateway.sh | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 scripts/start-gateway.sh diff --git a/scripts/start-gateway.sh b/scripts/start-gateway.sh new file mode 100755 index 0000000..15d10ab --- /dev/null +++ b/scripts/start-gateway.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# Telecom Platform API Gateway Startup Script +# This script starts the platform with Traefik as the API Gateway + +set -e + +echo "Starting Telecom Platform with API Gateway..." + +# Check for required environment variables +if [ -z "$JWT_SECRET" ]; then + echo "WARNING: JWT_SECRET not set, using default for development only" + export JWT_SECRET="change-me-in-production-jwt-secret-32-chars-min" +fi + +# Create necessary directories +mkdir -p traefik/dynamic + +# Stop any existing containers +echo "Stopping existing containers..." +docker-compose down + +# Build and start services +echo "Building and starting services with API Gateway..." +docker-compose up --build -d + +# Wait for services to be ready +echo "Waiting for services to be ready..." +sleep 10 + +# Check service health +echo "Checking service health..." + +# Check Traefik +if curl -f http://localhost:8080/ping >/dev/null 2>&1; then + echo "Traefik: OK" +else + echo "Traefik: FAILED" +fi + +# Check API Server through gateway +if curl -f http://localhost/api/v1/health >/dev/null 2>&1; then + echo "API Server: OK" +else + echo "API Server: FAILED" +fi + +# Check Charging Engine through gateway +if curl -f http://localhost/v1/health >/dev/null 2>&1; then + echo "Charging Engine: OK" +else + echo "Charging Engine: FAILED" +fi + +echo "" +echo "API Gateway is running!" +echo "" +echo "Services:" +echo " - Traefik Dashboard: http://localhost:8080" +echo " - API Server: https://api.telecom.com/api/v1" +echo " - Charging Engine: https://api.telecom.com/v1/credit" +echo " - Carrier Connector: https://api.telecom.com/v1/es2" +echo " - Packet Gateway: https://api.telecom.com/v1/packet" +echo " - Web Dashboard: http://localhost:3000" +echo "" +echo "To add api.telecom.com to your hosts file:" +echo " echo '127.0.0.1 api.telecom.com' | sudo tee -a /etc/hosts" +echo "" +echo "To view logs:" +echo " docker-compose logs -f traefik" +echo " docker-compose logs -f api-server" +echo " docker-compose logs -f charging-engine"