Files
ai-job-application/stop.sh
T

44 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Stop script for AI Job Application server
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PID_FILE="$APP_DIR/.app.pid"
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
echo "Stopping AI Job Application server (PID: $PID)..."
kill "$PID" 2>/dev/null
# Give it a moment to shutdown gracefully
for i in {1..5}; do
if ! kill -0 "$PID" 2>/dev/null; then
break
fi
sleep 1
done
# Force kill if still running
if kill -0 "$PID" 2>/dev/null; then
echo "Force stopping PID $PID..."
kill -9 "$PID" 2>/dev/null
fi
rm -f "$PID_FILE"
echo "✓ Server stopped successfully."
else
echo "Server is not running (stale PID file found and removed)."
rm -f "$PID_FILE"
fi
else
# Check for any rogue tsx server.ts process
PIDS=$(pgrep -f "tsx server.ts" || pgrep -f "dist/server.cjs")
if [ -n "$PIDS" ]; then
echo "Stopping running server process(es): $PIDS"
kill $PIDS 2>/dev/null
echo "✓ Server stopped."
else
echo "AI Job Application server is not running."
fi
fi