cinema-studio-pro/status.sh
Manish Tanwar e1067b551e update
2026-01-27 18:36:53 +05:30

108 lines
3.8 KiB
Bash

#!/bin/bash
# ============================================================================
# Lux Studio - Server Status Check Script
# ============================================================================
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Read ports from .env files
BACKEND_PORT=5015
FRONTEND_PORT=3000
if [ -f "backend/.env" ]; then
BACKEND_PORT=$(grep -E "^BACKEND_PORT=" backend/.env | cut -d'=' -f2 | tr -d ' ')
fi
if [ -f "frontend/.env" ]; then
FRONTEND_PORT=$(grep -E "^FRONTEND_PORT=" frontend/.env | cut -d'=' -f2 | tr -d ' ')
fi
BACKEND_PORT=${BACKEND_PORT:-5015}
FRONTEND_PORT=${FRONTEND_PORT:-3000}
echo -e "${BLUE}════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE}📊 Lux Studio Server Status${NC}"
echo -e "${BLUE}════════════════════════════════════════════════════════════${NC}"
echo ""
# Check Backend
echo -e "${BLUE}🔧 Backend Server (Port ${BACKEND_PORT}):${NC}"
if [ -f "${PROJECT_ROOT}/.backend.pid" ]; then
BACKEND_PID=$(cat "${PROJECT_ROOT}/.backend.pid")
if ps -p $BACKEND_PID > /dev/null 2>&1; then
echo -e " Status: ${GREEN}✓ Running${NC}"
echo -e " PID: $BACKEND_PID"
if curl -s http://localhost:${BACKEND_PORT}/server-check.php > /dev/null 2>&1; then
echo -e " Health: ${GREEN}✓ Responding${NC}"
else
echo -e " Health: ${YELLOW}⚠ Not responding${NC}"
fi
else
echo -e " Status: ${RED}✗ Not running (stale PID file)${NC}"
fi
else
echo -e " Status: ${RED}✗ Not running${NC}"
fi
echo ""
# Check Frontend
echo -e "${BLUE}🎨 Frontend Server (Port ${FRONTEND_PORT}):${NC}"
if [ -f "${PROJECT_ROOT}/.frontend.pid" ]; then
FRONTEND_PID=$(cat "${PROJECT_ROOT}/.frontend.pid")
if ps -p $FRONTEND_PID > /dev/null 2>&1; then
echo -e " Status: ${GREEN}✓ Running${NC}"
echo -e " PID: $FRONTEND_PID"
if curl -s http://localhost:${FRONTEND_PORT} > /dev/null 2>&1; then
echo -e " Health: ${GREEN}✓ Responding${NC}"
else
echo -e " Health: ${YELLOW}⚠ Not responding${NC}"
fi
else
echo -e " Status: ${RED}✗ Not running (stale PID file)${NC}"
fi
else
echo -e " Status: ${RED}✗ Not running${NC}"
fi
echo ""
# URLs
echo -e "${BLUE}🌐 Application URLs:${NC}"
echo -e " • Frontend: ${GREEN}http://localhost:${FRONTEND_PORT}${NC}"
echo -e " • Backend API: ${GREEN}http://localhost:${BACKEND_PORT}${NC}"
echo ""
# Log files
echo -e "${BLUE}📝 Log Files:${NC}"
if [ -f "${PROJECT_ROOT}/backend-server.log" ]; then
echo -e " • Backend: ${GREEN}${PROJECT_ROOT}/backend-server.log${NC}"
echo -e " Last 3 lines:"
tail -3 "${PROJECT_ROOT}/backend-server.log" | sed 's/^/ /'
else
echo -e " • Backend: ${YELLOW}No log file${NC}"
fi
echo ""
if [ -f "${PROJECT_ROOT}/frontend-server.log" ]; then
echo -e " • Frontend: ${GREEN}${PROJECT_ROOT}/frontend-server.log${NC}"
echo -e " Last 3 lines:"
tail -3 "${PROJECT_ROOT}/frontend-server.log" | sed 's/^/ /'
else
echo -e " • Frontend: ${YELLOW}No log file${NC}"
fi
echo ""
# Commands
echo -e "${BLUE}💡 Useful Commands:${NC}"
echo -e " • View backend logs: ${GREEN}tail -f backend-server.log${NC}"
echo -e " • View frontend logs: ${GREEN}tail -f frontend-server.log${NC}"
echo -e " • Stop servers: ${GREEN}./stop.sh${NC}"
echo -e " • Restart: ${GREEN}./stop.sh && ./setup.sh${NC}"
echo ""