Files
quality_app/py_app/status_production.sh
Quality System Admin 9c19379810 updated backups solution
2025-11-03 22:18:56 +02:00

88 lines
2.6 KiB
Bash
Executable File

#!/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"
# Detect which installation we're running from
if [[ "$PWD" == *"/quality_app/"* ]]; then
LOG_DIR="/srv/quality_app/logs"
PROJECT_NAME="quality_app"
else
LOG_DIR="/srv/quality_recticel/logs"
PROJECT_NAME="quality_recticel"
fi
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 " • Project: $PROJECT_NAME"
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: $LOG_DIR/access.log"
echo " • Error Log: $LOG_DIR/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 $LOG_DIR/error.log"
echo " • View access log: tail -f $LOG_DIR/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