69 lines
1.6 KiB
Bash
Executable File
69 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Production Stop Script for Trasabilitate Application
|
|
# This script stops the Gunicorn WSGI server
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}✅ $1${NC}"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}❌ $1${NC}"
|
|
}
|
|
|
|
echo -e "${BLUE}🛑 Trasabilitate Application - Production Stop${NC}"
|
|
echo "=============================================="
|
|
|
|
PID_FILE="../run/trasabilitate.pid"
|
|
|
|
if [[ ! -f "$PID_FILE" ]]; then
|
|
print_warning "No PID file found. Server may not be running."
|
|
echo "PID file location: $PID_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
PID=$(cat "$PID_FILE")
|
|
|
|
if ps -p "$PID" > /dev/null 2>&1; then
|
|
echo "Stopping Trasabilitate application (PID: $PID)..."
|
|
|
|
# Send SIGTERM first (graceful shutdown)
|
|
kill "$PID"
|
|
|
|
# Wait for graceful shutdown
|
|
sleep 3
|
|
|
|
# Check if still running
|
|
if ps -p "$PID" > /dev/null 2>&1; then
|
|
print_warning "Process still running, sending SIGKILL..."
|
|
kill -9 "$PID"
|
|
sleep 1
|
|
fi
|
|
|
|
# Check if process is finally stopped
|
|
if ! ps -p "$PID" > /dev/null 2>&1; then
|
|
print_success "Application stopped successfully"
|
|
rm -f "$PID_FILE"
|
|
else
|
|
print_error "Failed to stop application (PID: $PID)"
|
|
exit 1
|
|
fi
|
|
else
|
|
print_warning "Process $PID not found. Cleaning up PID file..."
|
|
rm -f "$PID_FILE"
|
|
print_success "PID file cleaned up"
|
|
fi
|
|
|
|
echo ""
|
|
print_success "Trasabilitate application has been stopped" |