freeleaps-ops/apps/gitea-webhook-ambassador-python/fix_pid.sh

41 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Fix PID file issue
echo "🔧 Fixing PID file issue..."
# Find Python service process
PID=$(lsof -ti :8000 2>/dev/null)
if [ -n "$PID" ]; then
echo "✅ Found running Python service (PID: $PID)"
# Check if the process is our service
PROCESS=$(ps -p $PID -o comm= 2>/dev/null)
if echo "$PROCESS" | grep -q "python"; then
echo "🐍 Confirmed: Python version of Gitea Webhook Ambassador"
# Create PID file
echo $PID > service.pid
echo "✅ PID file created: service.pid"
# Verify PID file
if [ -f "service.pid" ]; then
STORED_PID=$(cat service.pid)
echo "📝 PID file content: $STORED_PID"
if [ "$STORED_PID" = "$PID" ]; then
echo "✅ PID file fixed successfully"
echo "💡 Now you can use './devbox stop' to stop the service"
else
echo "❌ PID file content does not match"
fi
else
echo "❌ Failed to create PID file"
fi
else
echo "⚠️ Port 8000 is occupied by another process"
fi
else
echo "❌ No running Python service found"
echo "💡 Please start the service first: './devbox start'"
fi