Sindbad~EG File Manager

Current Path : /usr/home/beeson/ThreeBody/bin/
Upload File :
Current File : /usr/home/beeson/ThreeBody/bin/checkEngine3.sh

#!/bin/sh

# Define Engine details
ENGINE_PORT=12350
RESTART_SCRIPT="/home/beeson/Threebody/bin/restartEngine3.sh"
LOG_FILE="/home/beeson/Threebody/logs/chron.log"

# Check if anything is listening on the port
if sockstat -4 -l | grep -q ":$ENGINE_PORT"; then
    echo "Engine3 is running."
 # Check if there are active connections
    CONNECTIONS=$(sockstat -4 -c | awk -v port="$ENGINE_PORT" '$6 ~ port {print $3}')
    if [ -n "$CONNECTIONS" ]; then
        echo "Active connections: $CONNECTIONS"
    else
        echo "No active connections."
    fi
else
    echo "Engine3 is NOT running. Restarting..."
    
    # Log the restart event with a timestamp
    echo "Restarted by checkEngine3 at $(date '+%Y-%m-%d %H:%M:%S')" >> "$LOG_FILE"
    
    # Restart the Engine
    sh "$RESTART_SCRIPT"
fi

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists