fix:优化wsl环境下的边缘设备执行逻辑

This commit is contained in:
Daniel
2026-04-07 02:06:43 +08:00
parent afec0980d4
commit 6b9b9d60b5
7 changed files with 439 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
PID_DIR="runtime/pids"
WORKER_PID_FILE="${PID_DIR}/worker.pid"
EDGE_CLIENT_PID_FILE="${PID_DIR}/edge_client.pid"
stop_by_pid_file() {
local name="$1"
local pid_file="$2"
if [ ! -f "$pid_file" ]; then
echo "[INFO] ${name} not running (no pid file)"
return
fi
local pid
pid="$(cat "$pid_file" 2>/dev/null || true)"
if [ -z "$pid" ]; then
rm -f "$pid_file"
echo "[INFO] ${name} pid file empty, cleaned"
return
fi
if kill -0 "$pid" >/dev/null 2>&1; then
kill "$pid" >/dev/null 2>&1 || true
sleep 1
if kill -0 "$pid" >/dev/null 2>&1; then
kill -9 "$pid" >/dev/null 2>&1 || true
fi
echo "[OK] ${name} stopped (pid ${pid})"
else
echo "[INFO] ${name} already stopped (stale pid ${pid})"
fi
rm -f "$pid_file"
}
stop_by_pid_file "edge client" "$EDGE_CLIENT_PID_FILE"
stop_by_pid_file "worker" "$WORKER_PID_FILE"