#!/bin/bash # Production Status Script for Trasabilitate Application # This script shows the current status of 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 - Status Check${NC}" echo "==============================================" PID_FILE="../run/trasabilitate.pid" if [[ ! -f "$PID_FILE" ]]; then print_error "Application is not running (no PID file found)" echo "To start the application, run: ./start_production.sh" exit 1 fi PID=$(cat "$PID_FILE") if ps -p "$PID" > /dev/null 2>&1; then print_success "Application is running (PID: $PID)" echo "" echo "📋 Process Information:" ps -p "$PID" -o pid,ppid,pcpu,pmem,etime,cmd --no-headers | while read line; do echo " $line" done echo "" echo "🌐 Server Information:" echo " • Listening on: 0.0.0.0:8781" echo " • Local URL: http://127.0.0.1:8781" echo " • Network URL: http://$(hostname -I | awk '{print $1}'):8781" echo "" echo "📁 Log Files:" echo " • Access Log: /srv/quality_recticel/logs/access.log" echo " • Error Log: /srv/quality_recticel/logs/error.log" echo "" echo "🔧 Quick Commands:" echo " • Stop server: ./stop_production.sh" echo " • Restart server: ./stop_production.sh && ./start_production.sh" echo " • View error log: tail -f /srv/quality_recticel/logs/error.log" echo " • View access log: tail -f /srv/quality_recticel/logs/access.log" echo "" # Check if the web server is responding if command -v curl > /dev/null 2>&1; then echo "🌐 Connection Test:" if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8781 | grep -q "200\|302\|401"; then print_success "Web server is responding" else print_warning "Web server may not be responding properly" fi fi else print_error "Process $PID not found (stale PID file)" print_warning "Cleaning up stale PID file..." rm -f "$PID_FILE" echo "To start the application, run: ./start_production.sh" exit 1 fi