packServer/backend/config/deploy.config.example.cjs
liufumingren 11ebb33966 feat(extension): 插件配置集中管理 + 桌面端策略安装 + 跨网下载修复
- 后端:sys_config 存插件配置(识别前缀/生效站点/模板),平台管理员 GET/PUT /api/web/admin/extension;
  插件读取 GET /api/web/extension/config(Redis 缓存 1 小时,保存即失效)
- 前端:平台管理 → 插件配置页(只维护前缀,单号正则由服务端生成)
- 插件:改为只拉取执行(每 5 分钟 + 手动同步),移除规则编辑/试跑/导入导出;安装包地址自动取最新发布
- 桌面端:工具 → 安装/卸载谷歌插件(生成 .reg + reg import 写 HKLM 策略,读注册表验证);
  跨网下载改走云端中转;局域网探测补排障日志;自动更新按包类型取 md5Exe/sizeExe
- 发布:npm run extension:publish(crx + updates.xml)、extension:zip(商店上传包),
  nginx 对 /download/extension/updates.xml 关缓存

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-01 03:16:26 +08:00

103 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 发布配置模板(提交到仓库)
*
* 复制为 config/deploy.config.local.cjs 后填入真实 SSH 信息:
* Copy-Item config/deploy.config.example.cjs config/deploy.config.local.cjs
*
* config/deploy.config.local.cjs 已被 .gitignore 忽略,禁止提交。
*/
module.exports = {
production: {
// ==================== SSH ====================
host: '__FILL_SSH_HOST__',
port: 22,
username: '__FILL_SSH_USERNAME__',
// 绝对路径;Windows 写法示例:C:/Users/you/.ssh/id_rsa
privateKeyPath: 'C:/Users/your-user/.ssh/id_rsa',
// ==================== 远端目录 ====================
// 双实例目录:${deployRoot}/v1、${deployRoot}/v2;
// ${deployRoot}/current.md 记录当前活跃版本,${deployRoot}/.deploy 存放发布包/备份/状态。
deployRoot: '/www/wwwroot/packService',
// v1 / v2 两个实例的监听端口(egg config.cluster.listen.port 由启动脚本的 PORT 覆盖)
ports: { v1: 7301, v2: 7302 },
// ==================== 健康检查 ====================
// /health 会同时检查 MySQL / Redis,任一不可用即 503
healthCheckPath: '/health',
healthCheckAttempts: 30,
healthCheckInterval: 2,
// Nginx upstream 文件(内容只有一行 proxy_pass)。置空字符串则不自动切换。
// 需要在 Nginx 配置里 include 这个文件,例如:
// upstream pack_service { include /www/wwwroot/packService/nginx-upstream.conf; }
nginxUpstreamFile: '/www/wwwroot/packService/nginx-upstream.conf',
// 服务端私有配置目录(不随发布包走):可放 config.prod.js / config.local.js;
// envFile 会在启动前被 source,用于 JWT_SECRET、数据库密码等环境变量。
sharedConfigDir: '/www/wwwroot/packService/shared-config',
envFile: 'env.prod.sh',
// 本机权威 env 副本(已 gitignore);存在时发布前自动上传到 shared-config/
envFileLocalPath: 'config/env.prod.sh',
uploadEnvFile: true,
// ==================== 发布内容 ====================
// 远端保留目录(清理旧代码时跳过)
sharedDirs: [ 'node_modules', 'logs', 'run', 'temp' ],
// 服务端私有文件/目录:发布前暂存、解压后放回,不会被发布包覆盖或删除。
// config/config.prod.js 需要运维在服务器上首次放置(数据库/Redis 密码等)。
preservePaths: [
'config/config.prod.js',
'config/config.local.js',
'app/public/download',
'app/public/version',
],
// 发布前本地构建 ../frontend,产物单独上传到 frontendDeployDir(由 nginx 托管)
buildFrontend: true,
frontendDir: '../frontend',
// 前端构建产物由 nginx 直接托管(上一版保留在 frontend.prev,供回退)
frontendDeployDir: '/www/wwwroot/packService/frontend',
// 由发布脚本维护的 nginx 前端/反代配置(站点配置里 include)
nginxFrontConf: '/www/wwwroot/packService/front.conf',
manageNginxFrontConf: true,
serverName: 'pack.example.com',
// 桌面端发布(npm run desktop:publish):只构建/上传安装包,不动后端
desktopBuildScript: '../desktop/installer/build.ps1',
desktopOutDir: '../desktop/installer/out',
// 安装包目录(nginx 长缓存):deployRoot/download/desktop/YuncangTraceSetup-x.y.z.msi
desktopDownloadDir: '/www/wwwroot/packService/download/desktop',
// version.json 目录(nginx 对 /download/version.json 关缓存,客户端路径不变)
desktopVersionDir: '/www/wwwroot/packService/download',
desktopBaseUrl: 'https://pack.example.com',
desktopKeepVersions: 5,
desktopOwner: 'www:www',
// Chrome 插件(npm run extension:publish):.crx + updates.xml 放这里
// nginx 对 /download/extension/updates.xml 关缓存,浏览器靠它自动升级
extensionDownloadDir: '/www/wwwroot/packService/download/extension',
// Android 设备端发布(npm run android:publish):同样只构建/上传 APK
androidBuildScript: 'android_client/build.ps1',
androidOutDir: 'android_client/out',
androidDownloadDir: '/www/wwwroot/packService/download/android_client',
androidVersionDir: '/www/wwwroot/packService/download/android_client',
androidBaseUrl: 'https://pack.example.com',
androidKeepVersions: 5,
androidOwner: 'www:www',
// 目标目录 npm install --production 后是否执行 npm run db:deploy
remoteDbDeploy: false,
// 保留最近多少个备份包(backup-*.tar.gz)
keepBackups: 5,
sshOptions: [
'StrictHostKeyChecking=accept-new',
],
},
};