#!/bin/bash
cd "$(dirname "$0")"

if [ -f "cursorpro.pid" ]; then
    PID=$(cat cursorpro.pid)
    if ps -p $PID > /dev/null 2>&1; then
        kill $PID
        echo "服务已停止 (PID: $PID)"
    else
        echo "服务未运行"
    fi
    rm -f cursorpro.pid
else
    echo "PID文件不存在"
    # 尝试查找并杀死进程
    pkill -f "python run.py" && echo "已停止所有相关进程"
fi
