feat(services): add infra-clean and infra-reset commands
- infra-clean: Remove infrastructure containers and volumes (DELETES DATA) - infra-reset: Clean and reinstall infrastructure (DELETES DATA) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
bfddd203ca
commit
54d3533c18
|
|
@ -481,6 +481,65 @@ infra_logs() {
|
|||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f postgres redis zookeeper kafka
|
||||
}
|
||||
|
||||
infra_clean() {
|
||||
log_warn "This will remove infrastructure containers and ALL DATA (postgres, redis, kafka)!"
|
||||
log_warn "All databases will be DELETED!"
|
||||
read -p "Are you sure? (y/N): " confirm
|
||||
|
||||
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
||||
log_step "Stopping infrastructure services..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" stop postgres redis kafka zookeeper
|
||||
|
||||
log_step "Removing infrastructure containers..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" rm -f postgres redis kafka zookeeper
|
||||
|
||||
log_step "Removing infrastructure volumes..."
|
||||
docker volume rm -f services_postgres_data services_redis_data 2>/dev/null || true
|
||||
|
||||
log_info "Infrastructure cleanup complete"
|
||||
log_info ""
|
||||
log_info "To reinstall, run:"
|
||||
log_info " ./deploy.sh infra-up"
|
||||
log_info " ./deploy.sh migrate"
|
||||
else
|
||||
log_info "Cleanup cancelled"
|
||||
fi
|
||||
}
|
||||
|
||||
infra_reset() {
|
||||
log_warn "This will RESET all infrastructure (clean + reinstall)!"
|
||||
log_warn "All databases will be DELETED and recreated!"
|
||||
read -p "Are you sure? (y/N): " confirm
|
||||
|
||||
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
||||
# Clean
|
||||
log_step "Stopping infrastructure services..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" stop postgres redis kafka zookeeper
|
||||
|
||||
log_step "Removing infrastructure containers..."
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" rm -f postgres redis kafka zookeeper
|
||||
|
||||
log_step "Removing infrastructure volumes..."
|
||||
docker volume rm -f services_postgres_data services_redis_data 2>/dev/null || true
|
||||
|
||||
# Reinstall
|
||||
log_step "Starting fresh infrastructure..."
|
||||
sleep 3
|
||||
infra_up
|
||||
|
||||
log_info "Waiting for infrastructure to be ready..."
|
||||
sleep 10
|
||||
|
||||
log_info "Infrastructure reset complete!"
|
||||
log_info ""
|
||||
log_info "Next steps:"
|
||||
log_info " 1. Restart application services: ./deploy.sh restart"
|
||||
log_info " 2. Or rebuild and restart: ./deploy.sh build && ./deploy.sh up"
|
||||
else
|
||||
log_info "Reset cancelled"
|
||||
fi
|
||||
}
|
||||
|
||||
# ===========================================================================
|
||||
# Single Service Operations
|
||||
# ===========================================================================
|
||||
|
|
@ -593,6 +652,12 @@ case "${1:-}" in
|
|||
infra-logs)
|
||||
infra_logs
|
||||
;;
|
||||
infra-clean)
|
||||
infra_clean
|
||||
;;
|
||||
infra-reset)
|
||||
infra_reset
|
||||
;;
|
||||
*)
|
||||
echo "RWA Backend Services Deployment Script"
|
||||
echo ""
|
||||
|
|
@ -624,6 +689,8 @@ case "${1:-}" in
|
|||
echo " infra-restart - Restart infrastructure services"
|
||||
echo " infra-status - Show infrastructure status and health"
|
||||
echo " infra-logs - View infrastructure logs"
|
||||
echo " infra-clean - Remove infrastructure containers and volumes (DELETES DATA)"
|
||||
echo " infra-reset - Clean and reinstall infrastructure (DELETES DATA)"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " identity-service, wallet-service, backup-service, planting-service,"
|
||||
|
|
|
|||
Loading…
Reference in New Issue