From 3f96c9c6502243b06efd4bb34a189e72e3a5557c Mon Sep 17 00:00:00 2001
From: yearning <10538594+wangweifeng1999@user.noreply.gitee.com>
Date: 星期一, 28 九月 2026 19:24:55 +0800
Subject: [PATCH] 复制项目

---
 scripts/lib.sh |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/scripts/lib.sh b/scripts/lib.sh
new file mode 100644
index 0000000..612db07
--- /dev/null
+++ b/scripts/lib.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+RUN_DIR="$ROOT/run"
+LOG_DIR="$ROOT/logs"
+BACKEND_PID="$RUN_DIR/backend.pid"
+FRONTEND_PID="$RUN_DIR/frontend.pid"
+BACKEND_PORT=8010
+FRONTEND_PORT=5174
+FRONTEND_DEV_PORT=5175
+# prod锛歜uild + vite preview @5174锛沝ev锛歷ite dev @5175
+FRONTEND_MODE="${FRONTEND_MODE:-prod}"
+
+vite_project_pgrep() {
+  pgrep -f "$ROOT/frontend/node_modules/.bin/vite" 2>/dev/null || true
+}
+
+mkdir -p "$RUN_DIR" "$LOG_DIR"
+
+is_running() {
+  local pid_file="$1"
+  [[ -f "$pid_file" ]] && kill -0 "$(cat "$pid_file")" 2>/dev/null
+}
+
+stop_pid_file() {
+  local pid_file="$1"
+  local name="$2"
+  if [[ -f "$pid_file" ]]; then
+    local pid
+    pid="$(cat "$pid_file")"
+    if kill -0 "$pid" 2>/dev/null; then
+      kill "$pid" 2>/dev/null || true
+      sleep 1
+      kill -9 "$pid" 2>/dev/null || true
+      echo "宸插仠姝� $name (PID $pid)"
+    fi
+    rm -f "$pid_file"
+  fi
+}

--
Gitblit v1.8.0