refactor(ecosystem): v2.0 统一PM2配置 — 14服务按服务器分配+autorestart强制+deploy远程部署
核心变更: - 从3个app扩展到14个app(全部纳入PM2管理) - 每服务标注server归属(BS-GZ-006~BS-SH-005) - autorestart强制开启(之前console-server没开导致138次崩溃) - 分级配置: basePM2(一般) vs criticalPM2(关键) - 迁移记录标注(迁自BS-GZ-006) - 新增deploy远程部署配置(6台服务器各一个target) - console-server专门标注"曾是崩溃循环138次的罪魁祸首" 原则: 不把所有东西塞给广州 · 每服务必归档 · autorestart必开
This commit is contained in:
parent
cf11f870f2
commit
7e7416fa53
@ -1,26 +1,146 @@
|
||||
// 部署根目录: 通过 DEPLOY_ROOT 环境变量统一配置
|
||||
// 默认 /opt/guanghu (ZY-SVR-TPL-2026-0426-001 标准)
|
||||
// ============================================================================
|
||||
// 光湖OS · 统一PM2生态系统配置 · v2.0
|
||||
// 签发: 铸渊 ICE-GL-ZY001 · 2026-05-24 · D112
|
||||
// 原则: 每服务必属一台服务器 · 每台服务器比例分配 · autorestart必须开启
|
||||
// ============================================================================
|
||||
|
||||
const path = require('path');
|
||||
const DEPLOY_ROOT = process.env.DEPLOY_ROOT || '/opt/guanghu';
|
||||
|
||||
// 统一PM2基础配置
|
||||
const basePM2 = {
|
||||
autorestart: true,
|
||||
max_restarts: 10,
|
||||
restart_delay: 3000,
|
||||
max_memory_restart: '300M',
|
||||
watch: false,
|
||||
env: { NODE_ENV: 'production' }
|
||||
};
|
||||
|
||||
// 高可用配置(关键服务)
|
||||
const criticalPM2 = {
|
||||
...basePM2,
|
||||
max_restarts: 20,
|
||||
max_memory_restart: '500M',
|
||||
instances: 1,
|
||||
exec_mode: 'fork'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
apps: [
|
||||
// ═══════════════════════════════════════════════
|
||||
// BS-GZ-006 · 广州 · 门面+仓库 (2核2GB)
|
||||
// 角色: 对外入口 + Forgejo仓库托管
|
||||
// 服务数: 5
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'guanghulab-portal',
|
||||
script: 'server.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'portal'),
|
||||
env: { PORT: 3000 },
|
||||
...criticalPM2,
|
||||
server: 'BS-GZ-006'
|
||||
},
|
||||
{
|
||||
name: 'guanghulab-git-sync',
|
||||
script: 'server.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'server/git-sync'),
|
||||
env: { PORT: 8082 },
|
||||
...basePM2,
|
||||
server: 'BS-GZ-006'
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// BS-SG-001 · 新加坡 · 铸渊大脑 (4核7.5GB)
|
||||
// 角色: 重型计算 · 思考中枢
|
||||
// 服务数: 9
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'guanghulab-vault',
|
||||
script: 'server.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'server/secrets-vault'),
|
||||
env: { PORT: 8080 },
|
||||
...criticalPM2,
|
||||
server: 'BS-SG-001',
|
||||
note: '迁自BS-GZ-006'
|
||||
},
|
||||
{
|
||||
name: 'console-server',
|
||||
script: 'server.js',
|
||||
cwd: path.join(DEPLOY_ROOT, '_deploy/console-server'),
|
||||
env: { PORT: 3901 },
|
||||
...criticalPM2,
|
||||
server: 'BS-SG-001',
|
||||
note: '迁自BS-GZ-006 · 曾是崩溃循环138次的罪魁祸首'
|
||||
},
|
||||
{
|
||||
name: 'zhuyuan-agent',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'zhuyuan-agent'),
|
||||
...basePM2,
|
||||
server: 'BS-SG-001',
|
||||
note: '迁自BS-GZ-006'
|
||||
},
|
||||
{
|
||||
name: 'hololake-agent',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'hololake-agent'),
|
||||
...basePM2,
|
||||
server: 'BS-SG-001',
|
||||
note: '迁自BS-GZ-006'
|
||||
},
|
||||
{
|
||||
name: 'guanghulab-mcp-server',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'mcp-servers/guanghulab-mcp-server'),
|
||||
env: { PORT: 8083 },
|
||||
...criticalPM2,
|
||||
server: 'BS-SG-001',
|
||||
note: '迁自BS-GZ-006 · 唤醒+大脑访问入口'
|
||||
},
|
||||
{
|
||||
name: 'glada-agent',
|
||||
script: 'service-entry.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'glada'),
|
||||
env: { PORT: 3900 },
|
||||
...basePM2,
|
||||
server: 'BS-SG-001'
|
||||
},
|
||||
{
|
||||
name: 'age-os-mcp',
|
||||
script: 'server.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'server/age-os/mcp-server'),
|
||||
env: { PORT: 3100 },
|
||||
...basePM2,
|
||||
server: 'BS-SG-001'
|
||||
},
|
||||
{
|
||||
name: 'ops-agent',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'ops-agent'),
|
||||
env: { PORT: 3950 },
|
||||
...basePM2,
|
||||
server: 'BS-SG-001'
|
||||
},
|
||||
{
|
||||
name: 'dingtalk-bot',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'dingtalk-bot'),
|
||||
env: { NODE_ENV: 'production', PORT: process.env.DINGTALK_BOT_PORT || 3005 }
|
||||
env: { PORT: 3005 },
|
||||
...basePM2,
|
||||
server: 'BS-SG-001'
|
||||
},
|
||||
// ═══════════════════════════════
|
||||
// repo-mcp 冰朔 · 端口3903
|
||||
// 仓库: bingshuo/guanghulab
|
||||
// ═══════════════════════════════
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// BS-SG-002 · 新加坡 · 面孔 (2核4GB)
|
||||
// 角色: MCP服务
|
||||
// 服务数: 2
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'repo-mcp-bs',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'mcp-servers/repo-mcp-server'),
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
REPO_MCP_PORT: '3903',
|
||||
REPO_MCP_SECRET: process.env.REPO_MCP_SECRET_BS || 'CHANGE_ME_BS',
|
||||
GITEA_TOKEN: process.env.GITEA_TOKEN_BS || '',
|
||||
@ -28,18 +148,21 @@ module.exports = {
|
||||
REPO_OWNER: 'bingshuo',
|
||||
REPO_NAME: 'guanghulab',
|
||||
REPO_DEFAULT_BRANCH: 'main'
|
||||
}
|
||||
},
|
||||
...criticalPM2,
|
||||
server: 'BS-SG-002',
|
||||
note: '迁自BS-GZ-006'
|
||||
},
|
||||
// ═══════════════════════════════
|
||||
// repo-mcp 之之 · 端口3904
|
||||
// 仓库: bingshuo/zhizhi
|
||||
// ═══════════════════════════════
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// BS-SG-003 · 新加坡 · 中继+MCP (2核4GB)
|
||||
// 服务数: 2
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'repo-mcp-zz',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'mcp-servers/repo-mcp-server'),
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
REPO_MCP_PORT: '3904',
|
||||
REPO_MCP_SECRET: process.env.REPO_MCP_SECRET_ZZ || 'CHANGE_ME_ZZ',
|
||||
GITEA_TOKEN: process.env.GITEA_TOKEN_ZZ || '',
|
||||
@ -47,7 +170,89 @@ module.exports = {
|
||||
REPO_OWNER: 'bingshuo',
|
||||
REPO_NAME: 'zhizhi',
|
||||
REPO_DEFAULT_BRANCH: 'main'
|
||||
}
|
||||
},
|
||||
...basePM2,
|
||||
server: 'BS-SG-003',
|
||||
note: '迁自BS-GZ-006'
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// ZY-SG-006 · 新加坡 · 语料+推理 (2核4GB)
|
||||
// 服务数: 1 (未来增加3B推理)
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'cos-corpus-sync',
|
||||
script: 'sync.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'server/corpus-sync'),
|
||||
...basePM2,
|
||||
server: 'ZY-SG-006',
|
||||
note: '未来在此部署3B推理服务'
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
// BS-SH-005 · 上海 · 国内节点 (2核4GB)
|
||||
// 服务数: 1
|
||||
// ═══════════════════════════════════════════════
|
||||
{
|
||||
name: 'cn-llm-relay',
|
||||
script: 'index.js',
|
||||
cwd: path.join(DEPLOY_ROOT, 'server/cn-llm-relay'),
|
||||
env: { PORT: 3900 },
|
||||
...basePM2,
|
||||
server: 'BS-SH-005',
|
||||
note: '国内LLM中继 · 未来企业客户国内接入点'
|
||||
}
|
||||
]
|
||||
],
|
||||
|
||||
// PM2 Deploy (远程部署配置)
|
||||
deploy: {
|
||||
'BS-GZ-006': {
|
||||
user: 'root',
|
||||
host: '43.139.217.141',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/guanghu',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only guanghulab-portal,guanghulab-git-sync'
|
||||
},
|
||||
'BS-SG-001': {
|
||||
user: 'root',
|
||||
host: '43.156.237.110',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/zhuyuan',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only guanghulab-vault,console-server,zhuyuan-agent,hololake-agent,guanghulab-mcp-server,glada-agent,age-os-mcp,ops-agent,dingtalk-bot'
|
||||
},
|
||||
'BS-SG-002': {
|
||||
user: 'root',
|
||||
host: '43.134.16.246',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/zhuyuan',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only repo-mcp-bs'
|
||||
},
|
||||
'BS-SG-003': {
|
||||
user: 'root',
|
||||
host: '43.153.193.169',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/zhuyuan',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only repo-mcp-zz'
|
||||
},
|
||||
'ZY-SG-006': {
|
||||
user: 'root',
|
||||
host: '43.153.203.105',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/zhuyuan',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only cos-corpus-sync'
|
||||
},
|
||||
'BS-SH-005': {
|
||||
user: 'root',
|
||||
host: '124.223.10.33',
|
||||
ref: 'origin/main',
|
||||
repo: 'https://guanghulab.com/code/bingshuo/guanghulab.git',
|
||||
path: '/opt/zhuyuan',
|
||||
'post-deploy': 'npm install && pm2 reload ecosystem.config.js --only cn-llm-relay'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user