同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、 packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件 - 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源) - 构建产物(bin/target/dist)与签名私钥仍按规则排除
This commit is contained in:
1 parent
5c0be49217
commit
2c0bfafd8d
269 files changed
+10372
-16435
No files matched your search
@@ -85,6 +85,17 @@ detect_node() {
|
||||
|
||||
check_port() { lsof -ti:"$1" 2>/dev/null | head -1 || true; }
|
||||
|
||||
opsxdb_health() {
|
||||
curl -fsS --max-time 2 "http://127.0.0.1:$SERVER_PORT/health" 2>/dev/null \
|
||||
| rg -q '"service"[[:space:]]*:[[:space:]]*"opsxdb"'
|
||||
}
|
||||
|
||||
opsxdb_vite() {
|
||||
local html
|
||||
html="$(curl -fsS --max-time 2 "http://127.0.0.1:$WEB_PORT/" 2>/dev/null)" || return 1
|
||||
[[ "$html" == *'<title>OpsxDB</title>'* && "$html" == *'/src/main.tsx'* ]]
|
||||
}
|
||||
|
||||
kill_port() {
|
||||
local pids
|
||||
pids="$(lsof -ti:"$1" 2>/dev/null || true)"
|
||||
@@ -119,10 +130,6 @@ ensure_npm() {
|
||||
warning "缺少 node_modules,正在 npm install..."
|
||||
npm install
|
||||
fi
|
||||
if [ ! -d "$SCRIPT_DIR/node_modules" ]; then
|
||||
warning "desktop 缺少依赖,正在安装..."
|
||||
npm install
|
||||
fi
|
||||
}
|
||||
|
||||
build_server() {
|
||||
@@ -145,13 +152,16 @@ wait_http() {
|
||||
}
|
||||
|
||||
start_server() {
|
||||
if curl -fsS "http://127.0.0.1:$SERVER_PORT/health" >/dev/null 2>&1; then
|
||||
if opsxdb_health; then
|
||||
success "后端已在运行 :$SERVER_PORT"
|
||||
return 0
|
||||
fi
|
||||
if [ -n "$(check_port "$SERVER_PORT")" ]; then
|
||||
error ":$SERVER_PORT 已被其他进程占用,不能启动 OpsxDB Gin;不会结束该进程"
|
||||
return 1
|
||||
fi
|
||||
info "启动后端 :$SERVER_PORT ..."
|
||||
: >"$SERVER_LOG"
|
||||
kill_port "$SERVER_PORT"
|
||||
build_server
|
||||
# 默认仅本机;对外需 OPSXDB_BIND_PUBLIC=1
|
||||
local bind_env="OPSXDB_ADDR=127.0.0.1:$SERVER_PORT"
|
||||
@@ -168,22 +178,29 @@ start_server() {
|
||||
|
||||
stop_server() {
|
||||
stop_detached "$SERVER_LABEL"
|
||||
kill_port "$SERVER_PORT"
|
||||
if opsxdb_health; then
|
||||
kill_port "$SERVER_PORT"
|
||||
elif [ -n "$(check_port "$SERVER_PORT")" ]; then
|
||||
warning ":$SERVER_PORT 由其他服务占用,未停止该进程"
|
||||
fi
|
||||
success "后端已停止"
|
||||
}
|
||||
|
||||
# 仅供桌面 Tauri devUrl / 打包源;不是浏览器产品入口
|
||||
start_vite_for_desktop() {
|
||||
if curl -fsS "http://127.0.0.1:$WEB_PORT/" >/dev/null 2>&1; then
|
||||
if opsxdb_vite; then
|
||||
success "桌面 UI(Vite) 已在运行 :$WEB_PORT"
|
||||
return 0
|
||||
fi
|
||||
if [ -n "$(check_port "$WEB_PORT")" ]; then
|
||||
error ":$WEB_PORT 已被其他服务占用,无法启动 OpsxDB 桌面 UI;不会结束该进程"
|
||||
return 1
|
||||
fi
|
||||
info "启动桌面 UI 源 :${WEB_PORT}(仅本机给 Tauri,勿当浏览器客户端)..."
|
||||
: >"$WEB_LOG"
|
||||
ensure_npm
|
||||
kill_port "$WEB_PORT"
|
||||
# Vite 用 nohup:launchctl submit 在本机对 npm -w 经常交不出进程(web.log 空、40s 超时)
|
||||
nohup /bin/bash -lc "export PATH=\"$NODE_BIN_DIR:/opt/homebrew/bin:/usr/local/bin:\$PATH\"; cd \"$SCRIPT_DIR\" && exec npm run" >>"$WEB_LOG" 2>&1 </dev/null &
|
||||
nohup /bin/bash -lc "export PATH=\"$NODE_BIN_DIR:/opt/homebrew/bin:/usr/local/bin:\$PATH\"; cd \"$SCRIPT_DIR\" && exec npm run dev:ui" >>"$WEB_LOG" 2>&1 </dev/null &
|
||||
wait_http "http://127.0.0.1:$WEB_PORT/" "Web UI" 80
|
||||
success "桌面 UI(Vite) UP http://127.0.0.1:${WEB_PORT}(请用 ./run.sh gui,勿当工作台)"
|
||||
}
|
||||
@@ -193,7 +210,11 @@ start_web() { start_vite_for_desktop; }
|
||||
|
||||
stop_web() {
|
||||
stop_detached "$WEB_LABEL"
|
||||
kill_port "$WEB_PORT"
|
||||
if opsxdb_vite; then
|
||||
kill_port "$WEB_PORT"
|
||||
elif [ -n "$(check_port "$WEB_PORT")" ]; then
|
||||
warning ":$WEB_PORT 由其他服务占用,未停止该进程"
|
||||
fi
|
||||
success "Web 已停止"
|
||||
}
|
||||
|
||||
@@ -202,6 +223,9 @@ start_desktop() {
|
||||
: >"$DESKTOP_LOG"
|
||||
ensure_npm
|
||||
kill_opsxdb_gui
|
||||
build_server
|
||||
prepare_sidecar
|
||||
npm run tauri -- build --debug --no-bundle
|
||||
ensure_gui_dev_app || return 1
|
||||
if [ "${GUI_DEV_NEEDS_VITE:-0}" = "1" ]; then
|
||||
start_vite_for_desktop
|
||||
@@ -232,15 +256,21 @@ stop_desktop() {
|
||||
|
||||
status() {
|
||||
echo "$PROJECT_NAME 状态"
|
||||
if curl -fsS "http://127.0.0.1:$SERVER_PORT/health" >/dev/null 2>&1; then
|
||||
if opsxdb_health; then
|
||||
success "server :$SERVER_PORT UP $(curl -fsS "http://127.0.0.1:$SERVER_PORT/health")"
|
||||
else
|
||||
warning "server :$SERVER_PORT DOWN"
|
||||
if [ -n "$(check_port "$SERVER_PORT")" ]; then
|
||||
warning ":$SERVER_PORT 被其他进程占用;桌面可使用独立动态端口"
|
||||
fi
|
||||
fi
|
||||
if curl -fsS "http://127.0.0.1:$WEB_PORT/" >/dev/null 2>&1; then
|
||||
if opsxdb_vite; then
|
||||
success "vite :${WEB_PORT} UP(桌面源,非浏览器产品)"
|
||||
else
|
||||
warning "vite :$WEB_PORT DOWN"
|
||||
if [ -n "$(check_port "$WEB_PORT")" ]; then
|
||||
warning ":$WEB_PORT 被其他服务占用"
|
||||
fi
|
||||
fi
|
||||
if curl -fsS "http://127.0.0.1:$SERVER_PORT/home" >/dev/null 2>&1 \
|
||||
|| curl -fsS "http://127.0.0.1:$SERVER_PORT/docs" >/dev/null 2>&1; then
|
||||
@@ -254,10 +284,7 @@ status() {
|
||||
}
|
||||
|
||||
|
||||
package_desktop() {
|
||||
info "构建桌面可安装包(含本机 sidecar)..."
|
||||
ensure_npm
|
||||
build_server
|
||||
prepare_sidecar() {
|
||||
local triple
|
||||
triple="$(rustc -vV 2>/dev/null | awk '/host:/ {print $2}')"
|
||||
if [ -z "$triple" ]; then
|
||||
@@ -269,12 +296,19 @@ package_desktop() {
|
||||
cp "$SCRIPT_DIR/$SERVER_DIR/bin/$SERVER_BIN" "$bin_dir/opsxdb-server-$triple"
|
||||
chmod +x "$bin_dir/opsxdb-server-$triple"
|
||||
success "sidecar → binaries/opsxdb-server-$triple"
|
||||
}
|
||||
|
||||
package_desktop() {
|
||||
info "构建桌面可安装包(含本机 sidecar)..."
|
||||
ensure_npm
|
||||
build_server
|
||||
prepare_sidecar
|
||||
(
|
||||
cd "$SCRIPT_DIR/apps/desktop"
|
||||
cd "$SCRIPT_DIR"
|
||||
export VITE_OPSXDB_API="http://127.0.0.1:$SERVER_PORT"
|
||||
npm run tauri -- build
|
||||
)
|
||||
success "桌面包构建完成(见 apps/desktop/src-tauri/target/release/bundle)"
|
||||
success "桌面包构建完成(见 src-tauri/target/release/bundle)"
|
||||
}
|
||||
|
||||
usage() {
|
||||
@@ -308,7 +342,11 @@ start_web_scene() {
|
||||
|
||||
start_gui_scene() {
|
||||
if [ "$GUI_WITH_SERVER" = "1" ]; then
|
||||
start_server
|
||||
if [ -n "$(check_port "$SERVER_PORT")" ] && ! opsxdb_health; then
|
||||
warning ":$SERVER_PORT 已被其他服务占用;桌面将自起独立后端"
|
||||
else
|
||||
start_server
|
||||
fi
|
||||
else
|
||||
info "跳过 Gin(OPSXDB_GUI_WITH_SERVER=0);桌面 HTTP 走 tauri-native"
|
||||
fi
|
||||
@@ -334,6 +372,7 @@ case "$cmd" in
|
||||
gui|desktop-scene) start_gui_scene ;;
|
||||
all) start_all_scene ;;
|
||||
server) start_server ;;
|
||||
prepare) build_server; prepare_sidecar ;;
|
||||
package|dist) package_desktop ;;
|
||||
web-only|vite)
|
||||
warning "已弃用浏览器工作台。Vite 仅桌面源;请用: ./run.sh gui"
|
||||
|
||||
Reference in new issue
Block a user