Files
sanguo_quant_live/stop-watcher.sh
T
2026-03-26 00:39:09 +08:00

38 lines
839 B
Bash
Executable File

#!/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)"
exit 0
fi
pid=$(cat "$PID_FILE")
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"
else
echo "Process $pid not found, removing stale PID file"
rm -f "$PID_FILE"
fi