class_hour_record/.cozeproj/scripts/pack.sh

24 lines
653 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# build_weapp.sh - 通过 PID 文件精确杀掉自己上次的构建进程
PID_FILE="/tmp/coze-build_weapp.pid"
# 杀掉上次的构建进程组
if [ -f "$PID_FILE" ]; then
OLD_PID=$(cat "$PID_FILE")
if kill -0 "$OLD_PID" 2>/dev/null; then
echo "正在终止上次的构建进程组 (PID: $OLD_PID)..."
# 关键kill 负数 PID = 杀掉整个进程组
kill -9 -"$OLD_PID" 2>/dev/null
sleep 1
fi
rm -f "$PID_FILE"
fi
# 用 setsid 创建新的进程组,方便下次整组杀掉
setsid pnpm build:pack &
echo $! > "$PID_FILE"
echo "构建已启动 (PID: $(cat $PID_FILE))"
wait $!
rm -f "$PID_FILE"