cheekylist/dev.sh
2025-07-25 14:41:43 +02:00

65 lines
No EOL
1.6 KiB
Bash
Executable file

#!/bin/bash
# Function to cleanup processes
cleanup() {
echo ""
echo "🛑 Shutting down processes..."
# Kill child processes
if [ ! -z "$AIR_PID" ]; then
echo " Stopping Air server (PID: $AIR_PID)..."
kill $AIR_PID 2>/dev/null || true
fi
if [ ! -z "$VITE_PID" ]; then
echo " Stopping Vite server (PID: $VITE_PID)..."
kill $VITE_PID 2>/dev/null || true
fi
# Kill any remaining processes
pkill -f "gocheck" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
pkill -f "esbuild" 2>/dev/null || true
pkill -f "air" 2>/dev/null || true
echo "✅ All processes stopped"
exit 0
}
# Set up signal handlers
trap cleanup SIGINT SIGTERM
# Kill any existing processes
echo "🔄 Cleaning up existing processes..."
pkill -f "gocheck" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
pkill -f "esbuild" 2>/dev/null || true
pkill -f "air" 2>/dev/null || true
sleep 1
# Verify processes are killed
if pgrep -f "gocheck\|vite\|esbuild\|air" > /dev/null; then
echo "⚠️ Some processes are still running. Force killing..."
pkill -9 -f "gocheck" 2>/dev/null || true
pkill -9 -f "vite" 2>/dev/null || true
pkill -9 -f "esbuild" 2>/dev/null || true
pkill -9 -f "air" 2>/dev/null || true
sleep 1
fi
echo "✅ Process cleanup completed"
# Run the server
echo "🚀 Starting Go server with Air..."
air &
AIR_PID=$!
# Run the frontend
echo "🎨 Starting frontend development server..."
sleep 2
cd frontend && npm run dev &
VITE_PID=$!
# Wait for both processes
echo "📡 Development servers running. Press Ctrl+C to stop."
wait