#!/bin/bash # URL Tracker Tool V2 - Service Stop Script # This script stops both API and Frontend services cleanly echo "$(date): Stopping URL Tracker Tool V2 services..." >> /var/log/catch-redirect.log # Stop API service if [ -f /var/run/catch-redirect-api.pid ]; then API_PID=$(cat /var/run/catch-redirect-api.pid) echo "$(date): Stopping API service (PID: $API_PID)..." >> /var/log/catch-redirect.log kill $API_PID 2>/dev/null || true rm -f /var/run/catch-redirect-api.pid fi # Stop Frontend service if [ -f /var/run/catch-redirect-frontend.pid ]; then FRONTEND_PID=$(cat /var/run/catch-redirect-frontend.pid) echo "$(date): Stopping Frontend service (PID: $FRONTEND_PID)..." >> /var/log/catch-redirect.log kill $FRONTEND_PID 2>/dev/null || true rm -f /var/run/catch-redirect-frontend.pid fi # Force kill any remaining processes pkill -f "node dist/index.js" || true pkill -f "serve dist" || true echo "$(date): All services stopped" >> /var/log/catch-redirect.log