feat(config): 添加 Node.js 堆内存配置和代理路径规范化
- 在 .env.sample 中新增 NODE_MAX_OLD_SPACE_SIZE 配置项,默认设置为 8192 MiB - 在 docker-compose.yml 中添加 NODE_OPTIONS 环境变量配置 - 在 easyai-proxy.conf.sample 中添加 /api 路径规范化重定向规则 - 修改 https.sh 脚本优先使用完整代理模板生成配置文件 - 更新 README.md 添加新版本发布说明 - 扩展测试脚本验证代理配置和路径重定向功能
This commit is contained in:
@@ -30,6 +30,9 @@ WEB_PORT=3010
|
||||
SERVER_HTTP_PORT=3001
|
||||
# easyai-server 后端 HTTP 端口
|
||||
|
||||
NODE_MAX_OLD_SPACE_SIZE=8192
|
||||
# easyai-server 的 Node.js V8 old-space 堆上限,单位 MiB
|
||||
|
||||
MALLOC_ARENA_MAX=2
|
||||
# 限制 glibc native heap arena,降低 sharp/libvips 场景下 RSS 膨胀
|
||||
MALLOC_TRIM_THRESHOLD_=131072
|
||||
|
||||
@@ -209,6 +209,11 @@ $env:UPDATE_NO_WAIT = "1"
|
||||
2. **新装与升级迁移**:Linux/macOS 和 Windows 启动、升级脚本会在重建服务前初始化并校验公开 API 地址,支持 IP 自定义 `SERVER_HTTP_PORT`、HTTP/HTTPS 域名和 `DEPLOY_PUBLIC_API_BASE_URL` 高级覆盖。
|
||||
3. **代理端口透传**:新 Nginx 模板为 `/api/`、`/mcp` 补齐公开 Host/Port Header;已有生成配置不会自动改写。
|
||||
|
||||
### 2026.07.15
|
||||
|
||||
1. **主服务 Node.js 堆内存上限**:`easyai-server` 默认通过 `NODE_OPTIONS` 将 V8 old-space 堆上限设置为 8192 MiB,可在 `.env` 中使用 `NODE_MAX_OLD_SPACE_SIZE` 覆盖。该值只限制 V8 堆,不包含 Buffer、sharp/libvips 等 native 内存。
|
||||
2. **生效要求**:该参数仅在创建 Node.js 进程时读取,更新部署文件后需要在合适的维护窗口重建 `easyai-server` 容器。
|
||||
|
||||
### 2026.06.24
|
||||
|
||||
1. **主服务 sharp/native 内存护栏**:`easyai-server` 默认关闭 sharp/libvips cache,并将 sharp 并发限制为 1;同时设置 `MALLOC_ARENA_MAX=2`、`MALLOC_TRIM_THRESHOLD_=131072`、`MALLOC_MMAP_THRESHOLD_=131072`、`MALLOC_TOP_PAD_=131072`,降低图片处理和大 Buffer 场景下 native RSS 持续膨胀风险。
|
||||
|
||||
@@ -68,6 +68,8 @@ services:
|
||||
# - ./data/backend/pm2.config.js:/app/pm2.config.js
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# Node.js V8 old-space 堆上限(MiB),可在 .env 中覆盖
|
||||
- NODE_OPTIONS=--max-old-space-size=${NODE_MAX_OLD_SPACE_SIZE:-8192}
|
||||
# MongoDB配置,用户管理,不会配置的话保持默认即可
|
||||
- CONFIG_DB_MONGO_URI=mongodb://172.21.0.3:27017
|
||||
- CONFIG_DB_MONGO_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
|
||||
|
||||
@@ -89,6 +89,11 @@ server {
|
||||
add_header Cross-Origin-Resource-Policy "cross-origin" always;
|
||||
}
|
||||
|
||||
# 规范化 API 根路径,确保 https://example.com/api 不会落到前端 location /。
|
||||
location = /api {
|
||||
return 308 /api/;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:3001/;
|
||||
proxy_read_timeout 1200s; # 您已设置,适合长连接
|
||||
|
||||
@@ -185,6 +185,14 @@ create_conf_by_template() {
|
||||
local domain=$1
|
||||
local target_file=$2
|
||||
|
||||
# 始终优先使用仓库维护的完整代理模板,避免仅生成前端 location /。
|
||||
if [ -f "./easyai-proxy.conf.sample" ]; then
|
||||
cp "./easyai-proxy.conf.sample" "./$target_file"
|
||||
sed -i.bak "s/51easyai\.com/$domain/g" "./$target_file"
|
||||
rm -f "./$target_file.bak"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -f "./demo.51easyai.com.conf" ]; then
|
||||
cp "./demo.51easyai.com.conf" "./$target_file"
|
||||
sed -i.bak "s/www\.demo\.51easyai\.com/www.$domain/g; s/demo\.51easyai\.com/$domain/g" "./$target_file"
|
||||
|
||||
@@ -8,6 +8,7 @@ trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
cp \
|
||||
"$REPO_ROOT/start.sh" \
|
||||
"$REPO_ROOT/https.sh" \
|
||||
"$REPO_ROOT/docker-compose.yml" \
|
||||
"$REPO_ROOT/.env.sample" \
|
||||
"$REPO_ROOT/.env.tools.sample" \
|
||||
@@ -29,6 +30,7 @@ reset_case() {
|
||||
.env.tools \
|
||||
.env.ASG \
|
||||
.env.AMS \
|
||||
easyai-proxy.conf \
|
||||
demo.example.com.conf
|
||||
}
|
||||
|
||||
@@ -57,6 +59,21 @@ grep -qx 'CONFIG_PUBLIC_API_BASE_URL=http://demo.example.com/api' .env
|
||||
grep -q 'proxy_set_header X-Forwarded-Host $easyai_forwarded_host;' demo.example.com.conf
|
||||
grep -q 'proxy_set_header X-Forwarded-Port $server_port;' demo.example.com.conf
|
||||
grep -q "proxy_set_header X-Original-Prefix '/api';" demo.example.com.conf
|
||||
grep -q 'location = /api {' demo.example.com.conf
|
||||
|
||||
# 直接验证 https.sh 的缺省配置生成函数会采用完整模板,而不是只代理 3010。
|
||||
eval "$(awk '
|
||||
/^create_conf_by_template\(\)/ { capture = 1 }
|
||||
/^conf_contains_domain\(\)/ { capture = 0 }
|
||||
capture { print }
|
||||
' https.sh)"
|
||||
create_conf_by_template demo.example.com easyai-proxy.conf
|
||||
grep -q 'server_name demo.example.com;' easyai-proxy.conf
|
||||
grep -q 'location = /api {' easyai-proxy.conf
|
||||
grep -q 'location /api/ {' easyai-proxy.conf
|
||||
grep -q 'proxy_pass http://127.0.0.1:3001/;' easyai-proxy.conf
|
||||
grep -q 'location /socket.io {' easyai-proxy.conf
|
||||
grep -q 'proxy_set_header X-Forwarded-Host $easyai_forwarded_host;' easyai-proxy.conf
|
||||
|
||||
reset_case
|
||||
DEPLOY_NON_INTERACTIVE=1 \
|
||||
|
||||
Reference in New Issue
Block a user