feat(services): add infrastructure management commands to deploy.sh
Add commands for managing infrastructure services separately: - infra-up: Start postgres, redis, zookeeper, kafka - infra-down: Stop infrastructure services - infra-restart: Restart infrastructure - infra-status: Show infrastructure status with health checks - infra-logs: View infrastructure service logs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3dc0fb15d8
commit
fdb3c132de
|
|
@ -4,15 +4,22 @@
|
|||
# =========================================
|
||||
#
|
||||
# Usage:
|
||||
# ./deploy.sh install # First time setup (generate secrets, init databases)
|
||||
# ./deploy.sh up # Start all services
|
||||
# ./deploy.sh down # Stop all services
|
||||
# ./deploy.sh restart # Restart all services
|
||||
# ./deploy.sh status # Show service status
|
||||
# ./deploy.sh logs [svc] # View logs (optional: specific service)
|
||||
# ./deploy.sh build # Rebuild all images
|
||||
# ./deploy.sh migrate # Run database migrations
|
||||
# ./deploy.sh health # Check health of all services
|
||||
# ./deploy.sh install # First time setup (generate secrets, init databases)
|
||||
# ./deploy.sh up # Start all services
|
||||
# ./deploy.sh down # Stop all services
|
||||
# ./deploy.sh restart # Restart all services
|
||||
# ./deploy.sh status # Show service status
|
||||
# ./deploy.sh logs [svc] # View logs (optional: specific service)
|
||||
# ./deploy.sh build # Rebuild all images
|
||||
# ./deploy.sh migrate # Run database migrations
|
||||
# ./deploy.sh health # Check health of all services
|
||||
#
|
||||
# Infrastructure:
|
||||
# ./deploy.sh infra-up # Start only infrastructure (postgres, redis, kafka)
|
||||
# ./deploy.sh infra-down # Stop infrastructure
|
||||
# ./deploy.sh infra-restart # Restart infrastructure
|
||||
# ./deploy.sh infra-status # Show infrastructure status
|
||||
# ./deploy.sh infra-logs # View infrastructure logs
|
||||
#
|
||||
|
||||
set -e
|
||||
|
|
@ -410,6 +417,70 @@ clean() {
|
|||
fi
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Infrastructure Operations
|
||||
# ===========================================================================
|
||||
|
||||
infra_up() {
|
||||
log_step "Starting infrastructure services..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d postgres redis zookeeper kafka
|
||||
log_info "Infrastructure services started"
|
||||
}
|
||||
|
||||
infra_down() {
|
||||
log_step "Stopping infrastructure services..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" stop postgres redis kafka zookeeper
|
||||
log_info "Infrastructure services stopped"
|
||||
}
|
||||
|
||||
infra_restart() {
|
||||
log_step "Restarting infrastructure services..."
|
||||
infra_down
|
||||
sleep 3
|
||||
infra_up
|
||||
}
|
||||
|
||||
infra_status() {
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo "Infrastructure Status"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" ps postgres redis zookeeper kafka
|
||||
|
||||
echo ""
|
||||
echo "Health Check:"
|
||||
|
||||
if docker exec rwa-postgres pg_isready -U rwa_user &>/dev/null; then
|
||||
echo -e " ${GREEN}[OK]${NC} PostgreSQL (port 5432)"
|
||||
else
|
||||
echo -e " ${RED}[FAIL]${NC} PostgreSQL (port 5432)"
|
||||
fi
|
||||
|
||||
if docker exec rwa-redis redis-cli ping &>/dev/null; then
|
||||
echo -e " ${GREEN}[OK]${NC} Redis (port 6379)"
|
||||
else
|
||||
echo -e " ${RED}[FAIL]${NC} Redis (port 6379)"
|
||||
fi
|
||||
|
||||
if docker exec rwa-zookeeper nc -z localhost 2181 &>/dev/null; then
|
||||
echo -e " ${GREEN}[OK]${NC} Zookeeper (port 2181)"
|
||||
else
|
||||
echo -e " ${RED}[FAIL]${NC} Zookeeper (port 2181)"
|
||||
fi
|
||||
|
||||
if docker exec rwa-kafka kafka-topics --bootstrap-server localhost:9092 --list &>/dev/null; then
|
||||
echo -e " ${GREEN}[OK]${NC} Kafka (port 9092)"
|
||||
else
|
||||
echo -e " ${RED}[FAIL]${NC} Kafka (port 9092)"
|
||||
fi
|
||||
}
|
||||
|
||||
infra_logs() {
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f postgres redis zookeeper kafka
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Single Service Operations
|
||||
# ===========================================================================
|
||||
|
|
@ -501,6 +572,21 @@ case "${1:-}" in
|
|||
rebuild-svc)
|
||||
rebuild_service "$2"
|
||||
;;
|
||||
infra-up)
|
||||
infra_up
|
||||
;;
|
||||
infra-down)
|
||||
infra_down
|
||||
;;
|
||||
infra-restart)
|
||||
infra_restart
|
||||
;;
|
||||
infra-status)
|
||||
infra_status
|
||||
;;
|
||||
infra-logs)
|
||||
infra_logs
|
||||
;;
|
||||
*)
|
||||
echo "RWA Backend Services Deployment Script"
|
||||
echo ""
|
||||
|
|
@ -526,6 +612,13 @@ case "${1:-}" in
|
|||
echo " stop-svc <name> - Stop a specific service"
|
||||
echo " rebuild-svc <name> - Rebuild and restart a specific service"
|
||||
echo ""
|
||||
echo "Infrastructure Commands:"
|
||||
echo " infra-up - Start infrastructure (postgres, redis, kafka)"
|
||||
echo " infra-down - Stop infrastructure services"
|
||||
echo " infra-restart - Restart infrastructure services"
|
||||
echo " infra-status - Show infrastructure status and health"
|
||||
echo " infra-logs - View infrastructure logs"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " identity-service, wallet-service, backup-service, planting-service,"
|
||||
echo " referral-service, reward-service, mpc-service, leaderboard-service,"
|
||||
|
|
|
|||
Loading…
Reference in New Issue