#!/bin/bash # # Check Visual Workflow Builder Backend Server Status # # This script checks if the server is running and displays status information # SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PID_FILE="$SCRIPT_DIR/.server.pid" LOG_FILE="$SCRIPT_DIR/server.log" # Colors for output GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo "==========================================" echo "Visual Workflow Builder - Server Status" echo "==========================================" # Check PID file if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") echo -e "${BLUE}PID File:${NC} $PID_FILE" echo -e "${BLUE}PID:${NC} $PID" # Check if process is running if ps -p $PID > /dev/null 2>&1; then echo -e "${GREEN}Status: RUNNING ✓${NC}" # Get process info echo "" echo "Process Information:" ps -p $PID -o pid,ppid,user,%cpu,%mem,etime,command else echo -e "${RED}Status: NOT RUNNING (stale PID file)${NC}" echo "The PID file exists but the process is not running" fi else echo -e "${YELLOW}PID File: Not found${NC}" echo -e "${RED}Status: NOT RUNNING${NC}" fi # Check port 5001 echo "" echo "Port 5001 Status:" PORT_CHECK=$(lsof -ti:5001 2>/dev/null) if [ -z "$PORT_CHECK" ]; then echo -e "${RED} Port 5001: FREE${NC}" else echo -e "${GREEN} Port 5001: IN USE${NC}" echo " Process(es) using port 5001:" lsof -i:5001 | grep -v COMMAND fi # Check if server responds echo "" echo "Health Check:" if command -v curl &> /dev/null; then HEALTH_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5001/health 2>/dev/null) if [ "$HEALTH_RESPONSE" = "200" ]; then echo -e "${GREEN} HTTP Response: 200 OK ✓${NC}" echo " Server is responding correctly" else echo -e "${RED} HTTP Response: $HEALTH_RESPONSE${NC}" echo " Server is not responding" fi else echo -e "${YELLOW} curl not available, skipping health check${NC}" fi # Show recent log entries if log file exists if [ -f "$LOG_FILE" ]; then echo "" echo "Recent Log Entries (last 10 lines):" echo "-----------------------------------" tail -n 10 "$LOG_FILE" fi echo "" echo "=========================================="