Compare commits
4
Commits
wave-3-done
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5df7ca1076 | ||
|
|
fe32751d92 | ||
|
|
fea806eb33 | ||
|
|
359a67b657 |
No files matched your search
+2
-2
@@ -353,7 +353,7 @@ http {
|
||||
# dev 用法:bash scripts/collect-plugin-dist.sh 后再启动 nginx。
|
||||
# ⚠️ 裸机/容器部署需把下方两处路径换成 ASSEMBLY_DIR 对应目录
|
||||
# (sso 仓 21c0f6f 同构,容器化收口见 task 3.9)。
|
||||
root /Users/xs/Desktop/workspace/ipass/ipass-ssw/build/shell;
|
||||
root /Users/xs/Documents/ipass/ipass-ssw/build/shell;
|
||||
index index.html;
|
||||
|
||||
location = / {
|
||||
@@ -452,7 +452,7 @@ http {
|
||||
# (Ruling 16,同 ipass-sso 21c0f6f 修复)。
|
||||
# ⚠️ 此处用了绝对路径,生产环境需替换为容器内路径或用 docker volume 挂载。
|
||||
location /static/plugins/ {
|
||||
alias /Users/xs/Desktop/workspace/ipass/ipass-ssw/build/static-plugins/;
|
||||
alias /Users/xs/Documents/ipass/ipass-ssw/build/static-plugins/;
|
||||
autoindex off;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"plugins":{"plugin-domain":{"enabled":true,"admin_prefix":"plugin-domain"},"plugin-llm":{"enabled":true,"admin_prefix":"plugin-llm"},"plugin-apix":{"enabled":true,"admin_prefix":"plugin-apix"}}}
|
||||
{"plugins":{"domain":{"enabled":true,"admin_prefix":"domain"},"llm":{"enabled":true,"admin_prefix":"llm"},"apix":{"enabled":true,"admin_prefix":"apix"}}}
|
||||
@@ -225,6 +225,11 @@ fn loc_switch(request: &mut Request, s: Switch) -> bool {
|
||||
/// 管理 API 分发:按 PLUGINS 顺序问每个插件,都不认领才统一 404。
|
||||
fn dispatch_api(r: *mut ngx_http_request_t) -> Status {
|
||||
for p in PLUGINS {
|
||||
// R19:被禁插件不认领路由(自然落到下面的统一 404)。
|
||||
// core 是网关身份底座,永不跳过;gateway-routes(trend)不在注册表内,恒启用。
|
||||
if p.name() != "core" && !ipass_core::plugin_registry::plugin_enabled(p.name()) {
|
||||
continue;
|
||||
}
|
||||
if let Some(s) = p.dispatch_api(r) {
|
||||
return s;
|
||||
}
|
||||
@@ -353,6 +358,14 @@ impl HttpModule for Module {
|
||||
unsafe extern "C" fn postconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
|
||||
let cf = unsafe { &mut *cf };
|
||||
|
||||
// R19:装载插件启停注册表。`ipass_data_dir` 指令在配置解析阶段已写入
|
||||
// store;postconfiguration 在 master 单次执行(reload 重进 = 热更新)。
|
||||
let cfg = ipass_core::plugin_registry::load(&format!(
|
||||
"{}/plugin-config.json",
|
||||
store::data_dir()
|
||||
));
|
||||
ipass_core::plugin_registry::set_current(cfg);
|
||||
|
||||
// 把本模块 ctx_index 注入内核契约:插件在 r->ctx 上挂请求级状态
|
||||
// (如 ipass-plugin-llm 的 usage_filter 扫描窗口)用它定位自己的槽位
|
||||
ipass_core::plugin::set_ctx_index(Module::module().ctx_index as usize);
|
||||
@@ -485,6 +498,12 @@ unsafe extern "C" fn init_process(_cycle: *mut ngx_cycle_t) -> ngx_int_t {
|
||||
Ok(false) => {}
|
||||
Err(e) => util::log_err(&format!("[ipass] 初始化管理员失败: {e}")),
|
||||
}
|
||||
// users.json 变更自动生效:后台扫描线程(**必须在 worker 期 spawn** ——
|
||||
// 共享内存是 MAP_SHARED,锁**不会**随 fork 复制成私有副本;真正的理由是
|
||||
// .so 数据段里的 Rust OnceLock(SPAWNED)在 fork 时是私有副本 ⇒ master 期
|
||||
// spawn 会让每个 worker 都命中「已初始化」而**根本不起线程**、特性静默失效。
|
||||
// 见 reloader.rs 顶部注释)
|
||||
ipass_core::reloader::worker_spawn();
|
||||
// 对话审计:确保目录存在 + 容量巡检一次(此后由请求写入节流触发)
|
||||
ipass_plugin_llm::llm_audit::startup();
|
||||
// 运行期统计:把上一次退出时落盘的快照灌回共享内存。
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
# - 核心壳来自 ipass-core/www(index.html + assets)
|
||||
# - 插件管理页是 UMD 产物,壳按
|
||||
# /static/plugins/<name>/dist/<name>-admin.umd.js 动态加载
|
||||
# (寻址约定见 ipass-core www/src/loader.ts,<name> 即 plugin-config.json 的键)
|
||||
# (寻址约定见 ipass-core www/src/loader.ts;R19 起 <name> 统一为
|
||||
# Plugin::name() 短名(domain/llm/apix),即 plugin-config.json 的键,
|
||||
# 也即 /api/core/plugins 返回的 name)
|
||||
# conf/nginx.conf 严禁把 /static/plugins/ alias 到 workspace 根——
|
||||
# 会连带暴露各仓 data/*.json 等敏感文件(曾犯,同 ipass-sso 21c0f6f 修复)。
|
||||
#
|
||||
# 输出布局(默认 ASSEMBLY_DIR=build,本机 dev,build/ 已整体 gitignore):
|
||||
# $ASSEMBLY_DIR/shell/ ← ../ipass-core/www/dist
|
||||
# $ASSEMBLY_DIR/static-plugins/<name>/dist/ ← ../ipass-<name>/www/dist(仅 enabled)
|
||||
# $ASSEMBLY_DIR/static-plugins/<name>/dist/ ← ../ipass-plugin-<name>/www/dist(仅 enabled)
|
||||
# (<name> = R19 统一后的短名 domain/llm/apix;UMD 产物原名 plugin-<name>-admin.umd.js,
|
||||
# 脚本另存一份 <name>-admin.umd.js 别名供壳按短名加载)
|
||||
#
|
||||
# 用法:
|
||||
# bash scripts/collect-plugin-dist.sh # → build/(dev,配合 conf/nginx.conf)
|
||||
@@ -45,13 +49,14 @@ CONFIG="$ROOT/data/plugin-config.json"
|
||||
PYTHON="${PYTHON:-python3}"
|
||||
command -v "$PYTHON" >/dev/null 2>&1 || { echo "!! 缺 python3(解析 plugin-config.json 用)" >&2; exit 1; }
|
||||
|
||||
# enabled 插件名清单(如 plugin-domain;对应仓库目录 ipass-<name>)
|
||||
# enabled 插件短名清单(R19 统一键 = Plugin::name(),如 domain;对应仓库 ipass-plugin-<短名>。
|
||||
# 兼容旧 plugin- 前缀拼写:一律去掉前缀再映射目录)
|
||||
PLUGINS="$("$PYTHON" - "$CONFIG" <<'PY'
|
||||
import json, sys
|
||||
cfg = json.load(open(sys.argv[1], encoding="utf-8"))
|
||||
for name, p in cfg.get("plugins", {}).items():
|
||||
if p.get("enabled"):
|
||||
print(name)
|
||||
print(name.removeprefix("plugin-"))
|
||||
PY
|
||||
)"
|
||||
|
||||
@@ -74,16 +79,23 @@ mkdir -p "$PLUGINS_OUT"
|
||||
find "$PLUGINS_OUT" -mindepth 1 -maxdepth 1 ! -name .gitkeep -exec rm -rf {} +
|
||||
|
||||
count=0
|
||||
while IFS= read -r name; do
|
||||
[ -n "$name" ] || continue
|
||||
src="$IPASS_DIR/ipass-${name}/www/dist"
|
||||
while IFS= read -r short; do
|
||||
[ -n "$short" ] || continue
|
||||
src="$IPASS_DIR/ipass-plugin-${short}/www/dist"
|
||||
if [ ! -d "$src" ]; then
|
||||
echo "!! $name:$src 缺失(先在 ipass-${name}/www 跑 npm run build),跳过" >&2
|
||||
echo "!! $short:$src 缺失(先在 ipass-plugin-${short}/www 跑 npm run build),跳过" >&2
|
||||
continue
|
||||
fi
|
||||
mkdir -p "$PLUGINS_OUT/$name/dist"
|
||||
rsync -a --delete "$src/" "$PLUGINS_OUT/$name/dist/"
|
||||
echo "plugin: $src → $PLUGINS_OUT/$name/dist"
|
||||
mkdir -p "$PLUGINS_OUT/$short/dist"
|
||||
rsync -a --delete "$src/" "$PLUGINS_OUT/$short/dist/"
|
||||
# 产物原文件名是 plugin-<短名>-admin.umd.js;壳按短名请求
|
||||
# /static/plugins/<短名>/dist/<短名>-admin.umd.js(loader.ts 约定)→ 补一份短名别名
|
||||
if [ ! -f "$PLUGINS_OUT/$short/dist/${short}-admin.umd.js" ] \
|
||||
&& [ -f "$PLUGINS_OUT/$short/dist/plugin-${short}-admin.umd.js" ]; then
|
||||
cp "$PLUGINS_OUT/$short/dist/plugin-${short}-admin.umd.js" \
|
||||
"$PLUGINS_OUT/$short/dist/${short}-admin.umd.js"
|
||||
fi
|
||||
echo "plugin: $src → $PLUGINS_OUT/$short/dist"
|
||||
count=$((count + 1))
|
||||
done <<EOF
|
||||
$PLUGINS
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
# bash tests/run.sh gateway # 只跑域名网关(102 条断言)
|
||||
# bash tests/run.sh llm # 只跑 LLM 代理
|
||||
#
|
||||
# 前置:本机 nginx 已编译好(默认 /Users/xs/Desktop/workspace/iPass/build/ngxbuild/nginx-1.30.4/objs/nginx),
|
||||
# 前置:本机 nginx 已编译好(默认 /Users/xs/Documents/ipass/ngxbuild/nginx-1.30.4/objs/nginx),
|
||||
# Rust 模块由本脚本自动 cargo build。
|
||||
# 可覆盖:NGINX_BIN / NGINX_BUILD_DIR / PY
|
||||
#
|
||||
@@ -19,8 +19,8 @@ set -uo pipefail
|
||||
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
REPO=$(cd "$HERE/.." && pwd)
|
||||
|
||||
NGINX_BIN=${NGINX_BIN:-/Users/xs/Desktop/workspace/iPass/build/ngxbuild/nginx-1.30.4/objs/nginx}
|
||||
NGINX_BUILD_DIR=${NGINX_BUILD_DIR:-/Users/xs/Desktop/workspace/iPass/build/ngxbuild/nginx-1.30.4/objs}
|
||||
NGINX_BIN=${NGINX_BIN:-/Users/xs/Documents/ipass/ngxbuild/nginx-1.30.4/objs/nginx}
|
||||
NGINX_BUILD_DIR=${NGINX_BUILD_DIR:-/Users/xs/Documents/ipass/ngxbuild/nginx-1.30.4/objs}
|
||||
MODULE="$REPO/rust/target/debug/libipass_gateway.dylib"
|
||||
|
||||
# python3:优先隔离的托管运行时,其次系统的
|
||||
|
||||
Reference in new issue
Block a user