diff --git a/management/stop-watcher.sh b/management/stop-watcher.sh index 9ed76bfa5..9cbbca888 100755 --- a/management/stop-watcher.sh +++ b/management/stop-watcher.sh @@ -1,38 +1,21 @@ #!/bin/bash -# 停止文件监控脚本 +# 停止文件监控器 +# ============================================ -PROJECT_DIR="/Users/chufeng/.openclaw/sanguo_projects/sanguo_quant_live" -PID_FILE="$PROJECT_DIR/watcher.pid" - -if [ ! -f "$PID_FILE" ]; then - echo "File watcher is not running (no PID file found)" +if [ ! -f "../watcher.pid" ]; then + echo "✓ No PID file found, watcher not running" exit 0 fi -pid=$(cat "$PID_FILE") +PID=$(cat "../watcher.pid") -if ps -p "$pid" > /dev/null 2>&1; then - echo "Stopping file watcher (PID: $pid)..." - kill "$pid" - - # 等待进程结束 - for i in {1..10}; do - if ! ps -p "$pid" > /dev/null 2>&1; then - break - fi - sleep 1 - done - - # 强制终止如果还活着 - if ps -p "$pid" > /dev/null 2>&1; then - echo "Force killing process..." - kill -9 "$pid" - fi - - rm -f "$PID_FILE" - echo "File watcher stopped" +if kill -0 $PID 2>/dev/null; then + echo "✓ Stopping file watcher (PID $PID)" + kill $PID + rm -f "../watcher.pid" + echo "✓ Stopped" else - echo "Process $pid not found, removing stale PID file" - rm -f "$PID_FILE" -fi \ No newline at end of file + echo "✓ Process $PID not running, removing PID file" + rm -f "../watcher.pid" +fi