#!/bin/bash

# Simple script to restart bank services
# Created: 2025-04-20

# Set the working directory to the script's location
cd "$(dirname "$0")"
echo "Working directory: $(pwd)"

# Configuration
COMPOSE_FILE="bank-services-docker-compose.yml"

# Check if the compose file exists
if [ ! -f "$COMPOSE_FILE" ]; then
    echo "ERROR: Compose file $COMPOSE_FILE not found in $(pwd)"
    exit 1
fi

echo "$(date '+%Y-%m-%d %H:%M:%S') Stopping any running bank services..."
docker compose -f "$COMPOSE_FILE" down

echo "$(date '+%Y-%m-%d %H:%M:%S') Rebuilding and starting bank services..."
docker compose -f "$COMPOSE_FILE" up --build -d

echo "$(date '+%Y-%m-%d %H:%M:%S') Bank services restart completed"
exit 0
