133 lines
4.1 KiB
Bash
Executable File
133 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Gitea Webhook Ambassador - Version Check Script
|
|
# Used to distinguish between Go and Python versions
|
|
|
|
echo "🔍 Checking Gitea Webhook Ambassador version..."
|
|
|
|
# Check port 8000 (Python version default port)
|
|
echo "📡 Checking port 8000 (Python version)..."
|
|
if lsof -i :8000 > /dev/null 2>&1; then
|
|
PID=$(lsof -ti :8000)
|
|
PROCESS=$(ps -p $PID -o comm= 2>/dev/null)
|
|
echo "✅ Port 8000 is occupied (PID: $PID, process: $PROCESS)"
|
|
|
|
# Check if it is a Python process
|
|
if echo "$PROCESS" | grep -q "python\|uvicorn"; then
|
|
echo "🐍 Detected Python version is running"
|
|
|
|
# Try to access Python version API
|
|
if curl -s http://localhost:8000/api/health > /dev/null 2>&1; then
|
|
echo "✅ Python version API is responsive"
|
|
echo "🌐 Access: http://localhost:8000"
|
|
echo "📊 Dashboard: http://localhost:8000/dashboard"
|
|
else
|
|
echo "⚠️ Python process exists but API is not responsive"
|
|
fi
|
|
else
|
|
echo "⚠️ Port 8000 is occupied by another process"
|
|
fi
|
|
else
|
|
echo "❌ Port 8000 is not occupied (Python version not running)"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Check port 8080 (Go version default port)
|
|
echo "📡 Checking port 8080 (Go version)..."
|
|
if lsof -i :8080 > /dev/null 2>&1; then
|
|
PID=$(lsof -ti :8080)
|
|
PROCESS=$(ps -p $PID -o comm= 2>/dev/null)
|
|
echo "✅ Port 8080 is occupied (PID: $PID, process: $PROCESS)"
|
|
|
|
# Check if it is a Go process
|
|
if echo "$PROCESS" | grep -q "gitea-webhook-ambassador"; then
|
|
echo "🚀 Detected Go version is running"
|
|
|
|
# Try to access Go version API
|
|
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
|
|
echo "✅ Go version API is responsive"
|
|
echo "🌐 Access: http://localhost:8080"
|
|
else
|
|
echo "⚠️ Go process exists but API is not responsive"
|
|
fi
|
|
else
|
|
echo "⚠️ Port 8080 is occupied by another process"
|
|
fi
|
|
else
|
|
echo "❌ Port 8080 is not occupied (Go version not running)"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Check PID file
|
|
echo "📁 Checking PID file..."
|
|
|
|
# Python version PID file
|
|
PYTHON_PID_FILE="/home/nicolas/freeleaps-ops/apps/gitea-webhook-ambassador-python/service.pid"
|
|
if [ -f "$PYTHON_PID_FILE" ]; then
|
|
PYTHON_PID=$(cat "$PYTHON_PID_FILE")
|
|
if ps -p $PYTHON_PID > /dev/null 2>&1; then
|
|
echo "✅ Python version PID file exists (PID: $PYTHON_PID)"
|
|
else
|
|
echo "⚠️ Python version PID file exists but process does not exist"
|
|
fi
|
|
else
|
|
echo "❌ Python version PID file does not exist"
|
|
fi
|
|
|
|
# Go version PID file (if exists)
|
|
GO_PID_FILE="/home/nicolas/freeleaps-ops/apps/gitea-webhook-ambassador/service.pid"
|
|
if [ -f "$GO_PID_FILE" ]; then
|
|
GO_PID=$(cat "$GO_PID_FILE")
|
|
if ps -p $GO_PID > /dev/null 2>&1; then
|
|
echo "✅ Go version PID file exists (PID: $GO_PID)"
|
|
else
|
|
echo "⚠️ Go version PID file exists but process does not exist"
|
|
fi
|
|
else
|
|
echo "❌ Go version PID file does not exist"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
# Summary
|
|
echo "📊 Summary:"
|
|
echo "----------------------------------------"
|
|
|
|
PYTHON_RUNNING=false
|
|
GO_RUNNING=false
|
|
|
|
# Check Python version
|
|
if lsof -i :8000 > /dev/null 2>&1; then
|
|
PID=$(lsof -ti :8000)
|
|
PROCESS=$(ps -p $PID -o comm= 2>/dev/null)
|
|
if echo "$PROCESS" | grep -q "python\|uvicorn"; then
|
|
PYTHON_RUNNING=true
|
|
fi
|
|
fi
|
|
|
|
# Check Go version
|
|
if lsof -i :8080 > /dev/null 2>&1; then
|
|
PID=$(lsof -ti :8080)
|
|
PROCESS=$(ps -p $PID -o comm= 2>/dev/null)
|
|
if echo "$PROCESS" | grep -q "gitea-webhook-ambassador"; then
|
|
GO_RUNNING=true
|
|
fi
|
|
fi
|
|
|
|
if [ "$PYTHON_RUNNING" = true ] && [ "$GO_RUNNING" = true ]; then
|
|
echo "⚠️ Both versions are running!"
|
|
echo "🐍 Python version: http://localhost:8000"
|
|
echo "🚀 Go version: http://localhost:8080"
|
|
elif [ "$PYTHON_RUNNING" = true ]; then
|
|
echo "✅ Currently running: Python version"
|
|
echo "🌐 Access: http://localhost:8000"
|
|
elif [ "$GO_RUNNING" = true ]; then
|
|
echo "✅ Currently running: Go version"
|
|
echo "🌐 Access: http://localhost:8080"
|
|
else
|
|
echo "❌ No version is running"
|
|
fi
|
|
|
|
echo "----------------------------------------" |