immortal-bnb/scripts/rollback.sh
caelum0x bea907f76e feat: Complete production readiness implementation
- Integrated all production features into main application flow
- Added metrics, tracing, caching, and health checks to API server
- Enhanced trade execution with circuit breakers and retry policies
- Integrated database persistence for trades and metrics
- Added structured logging and observability
- Enhanced middleware with missing validators and rate limiters
- Added comprehensive error handling and resilience patterns
2025-11-20 00:35:39 +03:00

52 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Rollback Script
# Rolls back to previous deployment version
set -e
echo "๐Ÿ”„ Starting rollback..."
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
ENVIRONMENT=${1:-staging}
PREVIOUS_VERSION=${2:-previous}
if [ "$ENVIRONMENT" = "production" ]; then
echo -e "${RED}โš ๏ธ WARNING: Rolling back PRODUCTION${NC}"
read -p "Are you sure? (yes/no): " -r
if [[ ! $REPLY =~ ^yes$ ]]; then
echo "Rollback cancelled"
exit 1
fi
fi
echo -e "${YELLOW}๐Ÿ›‘ Stopping current deployment...${NC}"
if [ "$ENVIRONMENT" = "production" ]; then
docker-compose -f docker-compose.prod.yml down
else
docker-compose -f docker-compose.staging.yml down
fi
echo -e "${YELLOW}๐Ÿ“ฆ Rolling back to version: ${PREVIOUS_VERSION}${NC}"
if [ "$ENVIRONMENT" = "production" ]; then
docker-compose -f docker-compose.prod.yml up -d
else
docker-compose -f docker-compose.staging.yml up -d
fi
echo -e "${YELLOW}โณ Waiting for service to restart...${NC}"
sleep 10
# Health check
HEALTH_CHECK_URL="http://localhost:3001/health"
if curl -f ${HEALTH_CHECK_URL} > /dev/null 2>&1; then
echo -e "${GREEN}โœ… Rollback successful!${NC}"
else
echo -e "${RED}โŒ Rollback health check failed${NC}"
exit 1
fi