refactor: config/apps 目录重组、文档重构、架构图收窄
- 中央:config/(prometheus,alertmanager,grafana)、apps/(tile-cache,topology-editor) - 边缘:config/(vmagent,blackbox,targets)、apps/(onvif-exporter) - env: TRAEFIK_PROVIDER、prometheus/env.example 详细说明 - 文档:README/doc 重构,EDGE_CACHE 合并到 EDGE_AGENT_CONFIG - targets.csv 更新流程说明,ARCHITECTURE 图收窄 Made-with: Cursor
This commit is contained in:
@@ -8,10 +8,13 @@
|
||||
|
||||
- **`.env`** - 环境变量配置文件(从 `env.example` 复制并修改)
|
||||
- **`docker-compose.yml`** - Docker Compose 服务定义(使用环境变量)
|
||||
- **`prometheus.yml.template`** - Prometheus 配置模板(部署时自动生成 `prometheus.yml`)
|
||||
- **`prometheus.yml`** - Prometheus 实际配置文件(由模板自动生成,不要手动编辑)
|
||||
- **`alert_rules.yml`** - Prometheus 告警规则配置
|
||||
- **`alertmanager/alertmanager.yml`** - Alertmanager 告警管理配置
|
||||
- **`config/`** - 配置目录
|
||||
- `prometheus/` - Prometheus 配置(prometheus.yml.template, prometheus.yml, alert_rules.yml)
|
||||
- `alertmanager/` - Alertmanager 配置(alertmanager.yml)
|
||||
- `grafana/` - Grafana 配置(provisioning, dashboards)
|
||||
- **`apps/`** - 自建应用源码
|
||||
- `tile-cache/` - 天地图瓦片缓存
|
||||
- `topology-editor/` - GPS 标注助手
|
||||
|
||||
## 快速开始
|
||||
|
||||
@@ -30,7 +33,7 @@
|
||||
|
||||
部署脚本会自动:
|
||||
- 加载 `.env` 文件中的环境变量
|
||||
- 从 `prometheus.yml.template` 生成 `prometheus.yml`
|
||||
- 从 `config/prometheus/prometheus.yml.template` 生成 `config/prometheus/prometheus.yml`
|
||||
- 创建数据目录并设置权限
|
||||
- 启动所有服务
|
||||
|
||||
@@ -108,7 +111,7 @@
|
||||
|
||||
| 参数 | 默认值 | 说明 |
|
||||
|------|--------|------|
|
||||
| `TIANDITU_TK` | (空) | **天地图密钥**,配置到 `.env` 中。启用后 tile-cache、拓扑助手「使用服务器缓存」及 Grafana Geomap 使用天地图底图时均使用此密钥,无需在浏览器或 Grafana 中填写。在 [天地图开放平台](https://console.tianditu.gov.cn/) 申请。 |
|
||||
| `TIANDITU_TK` | (空) | **天地图密钥**,配置到 `.env` 中。启用后 tile-cache 与 Grafana Geomap 使用天地图底图时均使用此密钥,无需在 Grafana 中填写。在 [天地图开放平台](https://console.tianditu.gov.cn/) 申请。 |
|
||||
| `TILE_CACHE_PORT` | 4090 | 瓦片缓存服务端口 |
|
||||
| `TILE_CACHE_DATA_DIR` | ./data/tile-cache | 瓦片缓存数据目录 |
|
||||
| `TILE_CACHE_TTL_DAYS` | 7 | 缓存老化时间(天),超过后该瓦片下次请求时重新向天地图拉取;可改为 15 等 |
|
||||
@@ -135,7 +138,8 @@
|
||||
| 参数 | 默认值 | 说明 |
|
||||
|------|--------|------|
|
||||
| `TRAEFIK_ENABLED` | true | 是否启用 Traefik 反向代理 |
|
||||
| `TRAEFIK_NETWORK` | traefik | Traefik 网络名称 |
|
||||
| `TRAEFIK_PROVIDER` | external | Traefik 来源:**internal**=本编排启动 Traefik;**external**=使用已有外部 Traefik |
|
||||
| `TRAEFIK_NETWORK` | traefik | Traefik 网络名称(external 时通常为 traefik;internal 时 deploy.sh 设为 central_default) |
|
||||
| `GRAFANA_DOMAIN` | grafana.example.com | Grafana 域名 |
|
||||
| `PROMETHEUS_DOMAIN` | prometheus.example.com | Prometheus 域名 |
|
||||
| `ALERTMANAGER_DOMAIN` | alertmanager.example.com | Alertmanager 域名 |
|
||||
@@ -145,11 +149,11 @@
|
||||
|
||||
**Traefik 配置说明**:
|
||||
- 启用 Traefik 后,服务将通过域名访问,不再直接暴露端口
|
||||
- 需要确保 Traefik 网络已创建:`docker network create traefik`(如果不存在)
|
||||
- 需要配置 DNS 解析,将域名指向 Traefik 服务器
|
||||
- **TRAEFIK_PROVIDER=internal**:本编排内启动 Traefik,监听 80/443,自动创建网络,无需外部 Traefik
|
||||
- **TRAEFIK_PROVIDER=external**:接入已有 Traefik,需 `docker network create traefik`(若不存在)
|
||||
- 需要配置 DNS 解析,将域名指向本机
|
||||
- VictoriaMetrics 通常不通过 Traefik 访问(边缘节点直接连接)
|
||||
- 如果使用 HTTPS,需要配置 Traefik 的 TLS 证书
|
||||
- `NETWORK_NAME` 必须与 Traefik 实际网络一致,否则 Traefik 无法转发
|
||||
|
||||
### Docker 网络配置
|
||||
|
||||
@@ -290,9 +294,9 @@ Docker Compose 配置文件,定义了所有服务的:
|
||||
|
||||
**注意**:此文件已配置为使用环境变量,一般不需要手动修改。
|
||||
|
||||
### prometheus.yml.template
|
||||
### config/prometheus/prometheus.yml.template
|
||||
|
||||
Prometheus 配置模板文件,包含:
|
||||
Prometheus 配置模板文件(位于 `config/prometheus/`),包含:
|
||||
- 全局配置(抓取间隔、评估间隔、集群名称)
|
||||
- 远程写入配置(接收边缘节点数据)
|
||||
- 抓取配置(抓取本地服务指标)
|
||||
@@ -301,18 +305,18 @@ Prometheus 配置模板文件,包含:
|
||||
|
||||
**注意**:
|
||||
- 此文件是模板,不要直接使用
|
||||
- 部署脚本会自动从此模板生成 `prometheus.yml`
|
||||
- 部署脚本会自动从此模板生成 `prometheus/prometheus.yml`
|
||||
- 修改配置应通过 `.env` 文件,而不是直接修改模板
|
||||
|
||||
### prometheus.yml
|
||||
### config/prometheus/prometheus.yml
|
||||
|
||||
Prometheus 实际配置文件,由 `prometheus.yml.template` 自动生成。
|
||||
|
||||
**注意**:
|
||||
- 此文件由部署脚本自动生成,**不要手动编辑**
|
||||
- 如果需要修改,应修改 `prometheus.yml.template` 和 `.env` 文件
|
||||
- 如果需要修改,应修改 `config/prometheus/prometheus.yml.template` 和 `.env` 文件
|
||||
|
||||
### alert_rules.yml
|
||||
### config/prometheus/alert_rules.yml
|
||||
|
||||
Prometheus 告警规则配置文件,定义了:
|
||||
- ONVIF 设备告警规则(设备离线、高温、存储不足)
|
||||
@@ -320,7 +324,7 @@ Prometheus 告警规则配置文件,定义了:
|
||||
|
||||
**注意**:此文件需要手动编辑,修改后需要重启 Prometheus 服务。
|
||||
|
||||
### alertmanager/alertmanager.yml
|
||||
### config/alertmanager/alertmanager.yml
|
||||
|
||||
Alertmanager 告警管理配置文件,定义了:
|
||||
- 告警路由规则
|
||||
@@ -343,7 +347,7 @@ Alertmanager 告警管理配置文件,定义了:
|
||||
|
||||
**A**:
|
||||
- 查看环境变量:`cat .env`
|
||||
- 查看生成的 Prometheus 配置:`cat prometheus.yml`
|
||||
- 查看生成的 Prometheus 配置:`cat config/prometheus/prometheus.yml`
|
||||
- 查看 Docker Compose 配置:`cat docker-compose.yml`
|
||||
|
||||
### Q3: 配置错误导致服务无法启动?
|
||||
@@ -361,9 +365,7 @@ Alertmanager 告警管理配置文件,定义了:
|
||||
# 备份所有配置文件
|
||||
tar -czf central-server-config-backup-$(date +%Y%m%d).tar.gz \
|
||||
.env \
|
||||
prometheus.yml.template \
|
||||
alert_rules.yml \
|
||||
alertmanager/alertmanager.yml \
|
||||
config/ \
|
||||
docker-compose.yml
|
||||
```
|
||||
|
||||
|
||||
7
central-server/apps/tile-cache/Dockerfile
Normal file
7
central-server/apps/tile-cache/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY apps/tile-cache/package.json apps/tile-cache/server.js ./
|
||||
RUN mkdir -p /app/cache
|
||||
ENV PORT=4090
|
||||
EXPOSE 4090
|
||||
CMD ["node", "server.js"]
|
||||
1
central-server/apps/tile-cache/package.json
Normal file
1
central-server/apps/tile-cache/package.json
Normal file
@@ -0,0 +1 @@
|
||||
{"name":"tianditu-tile-cache","version":"1.0.0","description":"Cache Tianditu WMTS tiles to reduce API key usage","main":"server.js"}
|
||||
227
central-server/apps/tile-cache/server.js
Normal file
227
central-server/apps/tile-cache/server.js
Normal file
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* 天地图瓦片缓存服务
|
||||
* - GET /vec/:z/:x/:y GET /cva/:z/:x/:y 返回瓦片(先读缓存,未命中或已过期则向天地图请求并写入缓存)
|
||||
* - 缓存老化:超过 CACHE_TTL_DAYS 天的瓦片视为过期,会重新拉取
|
||||
* - GET /api/cache/status 返回缓存统计与 TTL 配置
|
||||
*/
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '4090', 10);
|
||||
const TIANDITU_TK = (process.env.TIANDITU_TK || '').trim();
|
||||
const CACHE_DIR = path.resolve(process.env.CACHE_DIR || path.join(__dirname, 'cache'));
|
||||
const CACHE_TTL_DAYS = Math.max(1, parseInt(process.env.CACHE_TTL_DAYS || '7', 10));
|
||||
const CACHE_TTL_MS = CACHE_TTL_DAYS * 24 * 60 * 60 * 1000;
|
||||
const UPSTREAM_TIMEOUT_MS = Math.max(5000, parseInt(process.env.UPSTREAM_TIMEOUT_MS || '15000', 10));
|
||||
|
||||
const WMTS_BASE = 'https://t0.tianditu.gov.cn';
|
||||
|
||||
function log(msg, detail) {
|
||||
const d = detail != null ? ' ' + JSON.stringify(detail) : '';
|
||||
console.log('[tile-cache] ' + msg + d);
|
||||
}
|
||||
function logErr(msg, err) {
|
||||
console.error('[tile-cache] ' + msg, err && err.message ? err.message : err);
|
||||
}
|
||||
|
||||
function ensureCacheDir(layer) {
|
||||
const dir = path.join(CACHE_DIR, layer);
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
return dir;
|
||||
}
|
||||
|
||||
function tilePath(layer, z, x, y) {
|
||||
return path.join(CACHE_DIR, layer, String(z), String(x), String(y) + '.png');
|
||||
}
|
||||
|
||||
function serveTile(filePath, res) {
|
||||
const stream = fs.createReadStream(filePath);
|
||||
stream.on('error', () => {
|
||||
res.statusCode = 404;
|
||||
res.end();
|
||||
});
|
||||
res.setHeader('Content-Type', 'image/png');
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
stream.pipe(res);
|
||||
}
|
||||
|
||||
function fetchFromTianditu(layer, z, x, y, cb) {
|
||||
if (!TIANDITU_TK) {
|
||||
logErr('fetchFromTianditu: TIANDITU_TK not set', null);
|
||||
cb(new Error('TIANDITU_TK not set'));
|
||||
return;
|
||||
}
|
||||
let done = false;
|
||||
function once(err, buf) {
|
||||
if (done) return;
|
||||
done = true;
|
||||
cb(err, buf);
|
||||
}
|
||||
const subpath = layer === 'vec' ? 'vec_w' : 'cva_w';
|
||||
const url = `${WMTS_BASE}/${subpath}/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${layer === 'vec' ? 'vec' : 'cva'}&STYLE=default&TILEMATRIXSET=w&TILEMATRIX=${z}&TILEROW=${y}&TILECOL=${x}&FORMAT=tiles&tk=${encodeURIComponent(TIANDITU_TK)}`;
|
||||
log('upstream request', { layer, z, x, y });
|
||||
const req = https.get(url, (proxyRes) => {
|
||||
if (proxyRes.statusCode !== 200) {
|
||||
log('upstream non-200', { status: proxyRes.statusCode, layer, z, x, y });
|
||||
once(new Error(`Upstream ${proxyRes.statusCode}`));
|
||||
return;
|
||||
}
|
||||
const chunks = [];
|
||||
proxyRes.on('data', (chunk) => chunks.push(chunk));
|
||||
proxyRes.on('end', () => {
|
||||
log('upstream end', { layer, z, x, y, size: chunks.reduce((a, c) => a + c.length, 0) });
|
||||
once(null, Buffer.concat(chunks));
|
||||
});
|
||||
proxyRes.on('error', (e) => {
|
||||
logErr('upstream stream error', e);
|
||||
once(e);
|
||||
});
|
||||
});
|
||||
req.on('error', (e) => {
|
||||
logErr('upstream request error', e);
|
||||
once(e);
|
||||
});
|
||||
req.setTimeout(UPSTREAM_TIMEOUT_MS, () => {
|
||||
log('upstream timeout', { layer, z, x, y });
|
||||
req.destroy();
|
||||
once(new Error('Upstream timeout'));
|
||||
});
|
||||
}
|
||||
|
||||
function handleTile(layer, z, x, y, res) {
|
||||
const zNum = parseInt(z, 10);
|
||||
const xNum = parseInt(x, 10);
|
||||
const yNum = parseInt(y, 10);
|
||||
if (isNaN(zNum) || isNaN(xNum) || isNaN(yNum) || zNum < 0 || zNum > 20) {
|
||||
res.statusCode = 400;
|
||||
res.end('Bad tile');
|
||||
return;
|
||||
}
|
||||
const filePath = tilePath(layer, z, x, y);
|
||||
if (fs.existsSync(filePath)) {
|
||||
try {
|
||||
const stat = fs.statSync(filePath);
|
||||
const ageMs = Date.now() - stat.mtime.getTime();
|
||||
if (ageMs < CACHE_TTL_MS) {
|
||||
log('cache hit', { layer, z, x, y });
|
||||
serveTile(filePath, res);
|
||||
return;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
log('cache miss', { layer, z, x, y });
|
||||
fetchFromTianditu(layer, z, x, y, (err, buf) => {
|
||||
try {
|
||||
if (err) {
|
||||
log('tile 502', { layer, z, x, y, err: err && err.message });
|
||||
res.statusCode = 502;
|
||||
res.end(err.message || 'Upstream error');
|
||||
return;
|
||||
}
|
||||
const dir = path.dirname(filePath);
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
try {
|
||||
fs.writeFileSync(filePath, buf);
|
||||
} catch (e) {
|
||||
logErr('write cache error', e);
|
||||
}
|
||||
res.setHeader('Content-Type', 'image/png');
|
||||
res.setHeader('Cache-Control', 'public, max-age=86400');
|
||||
res.end(buf);
|
||||
log('tile sent', { layer, z, x, y });
|
||||
} catch (e) {
|
||||
logErr('handleTile response error', e);
|
||||
if (!res.headersSent) {
|
||||
res.statusCode = 500;
|
||||
res.end('Internal error');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function countCached(dir, acc) {
|
||||
if (!fs.existsSync(dir)) return acc;
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
for (const e of entries) {
|
||||
const p = path.join(dir, e.name);
|
||||
if (e.isDirectory()) countCached(p, acc);
|
||||
else acc.count++;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
log('request', { method: req.method, url: req.url });
|
||||
try {
|
||||
const urlStr = (req.url && req.url.length) ? req.url : '/';
|
||||
const u = new URL(urlStr, 'http://localhost');
|
||||
const p = u.pathname;
|
||||
|
||||
if (req.method === 'GET' && p === '/health') {
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.end('ok');
|
||||
return;
|
||||
}
|
||||
if (req.method === 'GET' && /^\/vec\/(\d+)\/(\d+)\/(\d+)$/.test(p)) {
|
||||
const [, z, x, y] = p.match(/^\/vec\/(\d+)\/(\d+)\/(\d+)$/);
|
||||
handleTile('vec', z, x, y, res);
|
||||
return;
|
||||
}
|
||||
if (req.method === 'GET' && /^\/cva\/(\d+)\/(\d+)\/(\d+)$/.test(p)) {
|
||||
const [, z, x, y] = p.match(/^\/cva\/(\d+)\/(\d+)\/(\d+)$/);
|
||||
handleTile('cva', z, x, y, res);
|
||||
return;
|
||||
}
|
||||
if (req.method === 'GET' && (p === '/api/cache/status' || p === '/api/cache/status/')) {
|
||||
let count = 0;
|
||||
try {
|
||||
count = countCached(CACHE_DIR, { count: 0 }).count;
|
||||
} catch (e) {
|
||||
logErr('countCached error', e);
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({ ok: true, cachedTiles: count, cacheTtlDays: CACHE_TTL_DAYS }));
|
||||
return;
|
||||
}
|
||||
|
||||
res.statusCode = 404;
|
||||
res.end('Not found');
|
||||
} catch (e) {
|
||||
logErr('Request handler error', e);
|
||||
if (!res.headersSent) {
|
||||
res.statusCode = 500;
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
res.end('Internal error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Tile cache listening on http://0.0.0.0:${PORT}`);
|
||||
if (!TIANDITU_TK) console.warn('TIANDITU_TK not set; tile requests will fail.');
|
||||
console.log(`Cache dir: ${CACHE_DIR}, TTL: ${CACHE_TTL_DAYS} days, upstream timeout: ${UPSTREAM_TIMEOUT_MS}ms`);
|
||||
|
||||
// 启动时请求一块瓦片并写日志,确认容器能否访问天地图
|
||||
if (!TIANDITU_TK) {
|
||||
log('startup probe skipped (TIANDITU_TK not set)', null);
|
||||
return;
|
||||
}
|
||||
const probeZ = 3, probeX = 1, probeY = 2;
|
||||
log('startup probe requesting vec/' + probeZ + '/' + probeX + '/' + probeY, null);
|
||||
fetchFromTianditu('vec', String(probeZ), String(probeX), String(probeY), (err, buf) => {
|
||||
if (err) {
|
||||
logErr('startup probe failed', err);
|
||||
return;
|
||||
}
|
||||
log('startup probe ok', { layer: 'vec', z: probeZ, x: probeX, y: probeY, size: buf ? buf.length : 0 });
|
||||
});
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
logErr('uncaughtException', err);
|
||||
});
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.error('[tile-cache] unhandledRejection', reason);
|
||||
});
|
||||
3
central-server/apps/topology-editor/.dockerignore
Normal file
3
central-server/apps/topology-editor/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
*.log
|
||||
.env*
|
||||
16
central-server/apps/topology-editor/Dockerfile
Normal file
16
central-server/apps/topology-editor/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
# GPS 标注助手:H5 采集 GPS + 编辑 targets.csv(构建上下文为 central-server)
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps/topology-editor/package.json ./
|
||||
RUN npm install --production
|
||||
|
||||
COPY apps/topology-editor/server.js ./
|
||||
COPY apps/topology-editor/public ./public
|
||||
|
||||
ENV PORT=4080
|
||||
EXPOSE 4080
|
||||
|
||||
# 运行时由 docker-compose 挂载 edge-agent/config 到 /config,并设置 CONFIG_DIR=/config
|
||||
CMD ["node", "server.js"]
|
||||
827
central-server/apps/topology-editor/package-lock.json
generated
Normal file
827
central-server/apps/topology-editor/package-lock.json
generated
Normal file
@@ -0,0 +1,827 @@
|
||||
{
|
||||
"name": "topology-editor",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "topology-editor",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"express": "^4.19.2"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.4",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
|
||||
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "~1.2.0",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"on-finished": "~2.4.1",
|
||||
"qs": "~6.14.0",
|
||||
"raw-body": "~2.5.3",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bound": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
||||
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"get-intrinsic": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-signature": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
|
||||
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/destroy": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/etag": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.22.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
|
||||
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "~1.20.3",
|
||||
"content-disposition": "~0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "~0.7.1",
|
||||
"cookie-signature": "~1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.3.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.0",
|
||||
"merge-descriptors": "1.0.3",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "~0.1.12",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "~6.14.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "~0.19.0",
|
||||
"serve-static": "~1.16.2",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "~2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
|
||||
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "~2.0.2",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/fresh": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
|
||||
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"depd": "~2.0.0",
|
||||
"inherits": "~2.0.4",
|
||||
"setprototypeof": "~1.2.0",
|
||||
"statuses": "~2.0.2",
|
||||
"toidentifier": "~1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ee-first": "1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
|
||||
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
|
||||
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
|
||||
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
|
||||
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "~2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.16.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
|
||||
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "~0.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
|
||||
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-list": "^1.0.0",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-list": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
||||
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-map": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
||||
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-weakmap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
||||
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/statuses": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/toidentifier": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
central-server/apps/topology-editor/package.json
Normal file
13
central-server/apps/topology-editor/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "topology-editor",
|
||||
"version": "0.1.0",
|
||||
"description": "拓扑标注助手:上传/下载 targets.csv,H5 采集 GPS 与地图校验。可与 central-server 或 edge-agent 同机运行。",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.19.2",
|
||||
"multer": "^1.4.5-lts.1"
|
||||
}
|
||||
}
|
||||
509
central-server/apps/topology-editor/public/index.html
Normal file
509
central-server/apps/topology-editor/public/index.html
Normal file
@@ -0,0 +1,509 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>拓扑标注助手(GPS → targets.csv)</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style>
|
||||
body {
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
|
||||
sans-serif;
|
||||
margin: 0;
|
||||
padding: 16px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
input,
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
button {
|
||||
margin-top: 12px;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.row {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.log {
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
#map-section {
|
||||
margin-top: 20px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
#map-section h2 {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
#map-container {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
background: #e8e8e8;
|
||||
}
|
||||
.map-tip {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
padding: 6px 12px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>拓扑标注助手</h1>
|
||||
<p style="font-size: 13px">
|
||||
与 central 同机运行时:先<strong>上传</strong>本机 <code>targets.csv</code>,在页面上选设备、补 GPS 或新建后<strong>下载</strong> CSV 部署到边缘。与 edge-agent 同机挂载 config 时可直接读写 <code>config/targets.csv</code>。
|
||||
</p>
|
||||
|
||||
<div id="upload-download-section" class="row" style="margin-top:12px; padding:10px; background:#f9f9f9; border-radius:6px;">
|
||||
<label>上传 / 下载 targets.csv</label>
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; align-items:center;">
|
||||
<input type="file" id="csv-file" accept=".csv" style="width:auto; max-width:200px;" />
|
||||
<button id="btn-upload">上传 CSV</button>
|
||||
<a id="btn-download" href="/api/download" download="targets.csv" style="padding:8px 12px; font-size:14px; background:#0d6efd; color:#fff; text-decoration:none; border-radius:4px;">下载 targets.csv</a>
|
||||
</div>
|
||||
<p id="mode-hint" style="font-size:12px; color:#666; margin:8px 0 0 0;"></p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>选择已有设备(可选,推荐)</label>
|
||||
<select id="existing">
|
||||
<option value="">(新建设备)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<p style="font-size: 13px">
|
||||
若是新建设备:先选上面的「(新建设备)」,再填写下列字段。
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<label>设备类型 (type)</label>
|
||||
<select id="type">
|
||||
<option value="topology">topology(哑设备/拓扑节点)</option>
|
||||
<option value="ping">ping(有 IP,可探测)</option>
|
||||
<option value="onvif">onvif(摄像头)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>设备名称 (name,唯一标识)</label>
|
||||
<input id="name" placeholder="例如 core_sw_1 / camera_front" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>角色 (role)</label>
|
||||
<select id="role">
|
||||
<option value="core_switch">core_switch</option>
|
||||
<option value="access_switch">access_switch</option>
|
||||
<option value="camera">camera</option>
|
||||
<option value="wireless_bridge">wireless_bridge</option>
|
||||
<option value="media_converter">media_converter</option>
|
||||
<option value="other">other</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>上联设备名称 (parent,可留空)</label>
|
||||
<input id="parent" placeholder="例如 core_sw_1" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>上联链路类型 (uplink_type)</label>
|
||||
<select id="uplink_type">
|
||||
<option value="">(无)</option>
|
||||
<option value="fiber">fiber(光纤)</option>
|
||||
<option value="copper">copper(铜缆)</option>
|
||||
<option value="wireless">wireless(无线)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>IP(可选,ping/onvif 用)</label>
|
||||
<input id="ip" placeholder="192.168.x.x" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>位置描述 (location,可选)</label>
|
||||
<input id="location" placeholder="例如:A栋3楼弱电井" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>经度 (lon)</label>
|
||||
<input id="lon" readonly />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label>纬度 (lat)</label>
|
||||
<input id="lat" readonly />
|
||||
</div>
|
||||
|
||||
<button id="btn-gps">获取当前 GPS 坐标</button>
|
||||
<button id="btn-save">保存到 targets.csv</button>
|
||||
|
||||
<div class="log" id="log"></div>
|
||||
|
||||
<section id="map-section">
|
||||
<h2>地图校验</h2>
|
||||
<div class="row">
|
||||
<label>天地图 TK(<a href="https://console.tianditu.gov.cn/" target="_blank" rel="noopener">申请密钥</a>,填一次即可)</label>
|
||||
<input id="tianditu-tk" type="text" placeholder="请输入您的天地图 tk" />
|
||||
</div>
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; align-items:center;">
|
||||
<button id="btn-load-map">加载天地图(直接)</button>
|
||||
<span id="cache-buttons" style="display:none;">
|
||||
<button id="btn-load-map-cache">加载天地图(使用服务器缓存)</button>
|
||||
</span>
|
||||
</div>
|
||||
<div id="map-container"></div>
|
||||
<p class="map-tip">点击地图可修正坐标;有经纬度后会自动打点并居中。</p>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const logEl = document.getElementById("log");
|
||||
const existingSelect = document.getElementById("existing");
|
||||
let existingTargets = [];
|
||||
let map = null;
|
||||
let marker = null;
|
||||
let accuracyCircle = null;
|
||||
let lastGpsAccuracyM = null;
|
||||
let mapSource = null;
|
||||
let leafletMap = null;
|
||||
let leafletMarker = null;
|
||||
let cacheBaseUrl = "";
|
||||
|
||||
function log(msg) {
|
||||
logEl.textContent = msg;
|
||||
}
|
||||
|
||||
function getTk() {
|
||||
return (document.getElementById("tianditu-tk").value || "").trim();
|
||||
}
|
||||
|
||||
function loadTiandituMap() {
|
||||
const tk = getTk();
|
||||
if (!tk) {
|
||||
log("请先填写天地图 TK 再加载地图。");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
localStorage.setItem("tianditu_tk", tk);
|
||||
} catch (e) {}
|
||||
if (window.T && window.T.Map) {
|
||||
initMap();
|
||||
return;
|
||||
}
|
||||
log("正在加载天地图…");
|
||||
const script = document.createElement("script");
|
||||
script.src = "https://api.tianditu.gov.cn/api?v=4.0&tk=" + encodeURIComponent(tk);
|
||||
script.onload = function () {
|
||||
log("天地图加载成功,可点击地图修正坐标。");
|
||||
initMap();
|
||||
};
|
||||
script.onerror = function () {
|
||||
log("天地图加载失败,请检查 TK 或网络。");
|
||||
};
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
function initMap() {
|
||||
if (map && mapSource === "tianditu") return;
|
||||
var T = window.T;
|
||||
if (!T || !T.Map) return;
|
||||
if (map) return;
|
||||
mapSource = "tianditu";
|
||||
map = new T.Map("map-container");
|
||||
map.centerAndZoom(new T.LngLat(116.4, 39.9), 12);
|
||||
map.addEventListener("click", function (e) {
|
||||
var ll = e.lnglat;
|
||||
var lat = Math.round(ll.lat * 1e6) / 1e6;
|
||||
var lon = Math.round(ll.lng * 1e6) / 1e6;
|
||||
document.getElementById("lat").value = lat;
|
||||
document.getElementById("lon").value = lon;
|
||||
updateMapMarker(lat, lon);
|
||||
log("已从地图点击设置坐标:lat=" + lat + ", lon=" + lon);
|
||||
});
|
||||
var latEl = document.getElementById("lat").value.trim();
|
||||
var lonEl = document.getElementById("lon").value.trim();
|
||||
if (latEl && lonEl) {
|
||||
var lat = parseFloat(latEl), lon = parseFloat(lonEl);
|
||||
if (!isNaN(lat) && !isNaN(lon)) updateMapMarker(lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
function loadLeafletThenInitCacheMap() {
|
||||
if (window.L && window.L.map) {
|
||||
initCacheMap();
|
||||
return;
|
||||
}
|
||||
log("正在加载地图库…");
|
||||
var link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css";
|
||||
link.integrity = "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=";
|
||||
link.crossOrigin = "";
|
||||
document.head.appendChild(link);
|
||||
var script = document.createElement("script");
|
||||
script.src = "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js";
|
||||
script.integrity = "sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=";
|
||||
script.crossOrigin = "";
|
||||
script.onload = function () {
|
||||
log("使用服务器缓存加载天地图,可点击地图修正坐标。");
|
||||
initCacheMap();
|
||||
};
|
||||
script.onerror = function () { log("Leaflet 加载失败"); };
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
function initCacheMap() {
|
||||
if (leafletMap) return;
|
||||
if (!cacheBaseUrl) { log("未配置缓存服务"); return; }
|
||||
document.getElementById("map-container").innerHTML = "";
|
||||
map = null;
|
||||
marker = null;
|
||||
mapSource = "leaflet";
|
||||
leafletMap = L.map("map-container").setView([39.9, 116.4], 12);
|
||||
L.tileLayer(cacheBaseUrl + "/vec/{z}/{x}/{y}", { attribution: "© 天地图" }).addTo(leafletMap);
|
||||
L.tileLayer(cacheBaseUrl + "/cva/{z}/{x}/{y}", { attribution: "" }).addTo(leafletMap);
|
||||
leafletMap.on("click", function (e) {
|
||||
var lat = Math.round(e.latlng.lat * 1e6) / 1e6;
|
||||
var lon = Math.round(e.latlng.lng * 1e6) / 1e6;
|
||||
document.getElementById("lat").value = lat;
|
||||
document.getElementById("lon").value = lon;
|
||||
updateMapMarker(lat, lon);
|
||||
log("已从地图点击设置坐标:lat=" + lat + ", lon=" + lon);
|
||||
});
|
||||
var latEl = document.getElementById("lat").value.trim();
|
||||
var lonEl = document.getElementById("lon").value.trim();
|
||||
if (latEl && lonEl) {
|
||||
var lat = parseFloat(latEl), lon = parseFloat(lonEl);
|
||||
if (!isNaN(lat) && !isNaN(lon)) updateMapMarker(lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
function updateMapMarker(lat, lon) {
|
||||
if (isNaN(lat) || isNaN(lon)) return;
|
||||
if (mapSource === "leaflet" && leafletMap) {
|
||||
if (leafletMarker) leafletMap.removeLayer(leafletMarker);
|
||||
leafletMarker = L.marker([lat, lon]).addTo(leafletMap);
|
||||
leafletMap.setView([lat, lon], 17);
|
||||
return;
|
||||
}
|
||||
if (window.T && map) {
|
||||
var T = window.T;
|
||||
if (marker) {
|
||||
map.removeOverLay(marker);
|
||||
marker = null;
|
||||
}
|
||||
if (accuracyCircle) {
|
||||
map.removeOverLay(accuracyCircle);
|
||||
accuracyCircle = null;
|
||||
}
|
||||
var lngLat = new T.LngLat(lon, lat);
|
||||
marker = new T.Marker(lngLat);
|
||||
map.addOverLay(marker);
|
||||
map.panTo(lngLat);
|
||||
map.setZoom(17);
|
||||
if (lastGpsAccuracyM != null && lastGpsAccuracyM > 0 && T.Circle) {
|
||||
try {
|
||||
accuracyCircle = new T.Circle(lngLat, lastGpsAccuracyM, {
|
||||
color: "#3388ff",
|
||||
weight: 1,
|
||||
opacity: 0.4,
|
||||
});
|
||||
map.addOverLay(accuracyCircle);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fillFormFromTarget(t) {
|
||||
document.getElementById("type").value = t.type || "topology";
|
||||
document.getElementById("name").value = t.name || "";
|
||||
document.getElementById("role").value = t.role || "other";
|
||||
document.getElementById("parent").value = t.parent || "";
|
||||
document.getElementById("uplink_type").value = t.uplink_type || "";
|
||||
document.getElementById("ip").value = t.ip || "";
|
||||
document.getElementById("location").value = t.location || "";
|
||||
document.getElementById("lat").value = t.lat || "";
|
||||
document.getElementById("lon").value = t.lon || "";
|
||||
if (t.lat && t.lon) {
|
||||
var lat = parseFloat(t.lat), lon = parseFloat(t.lon);
|
||||
if (!isNaN(lat) && !isNaN(lon)) updateMapMarker(lat, lon);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadExisting() {
|
||||
try {
|
||||
const resp = await fetch("/api/targets");
|
||||
if (!resp.ok) throw new Error("加载 targets.csv 失败");
|
||||
existingTargets = await resp.json();
|
||||
existingSelect.innerHTML =
|
||||
'<option value="">(新建设备)</option>' +
|
||||
existingTargets
|
||||
.map(
|
||||
(t) =>
|
||||
`<option value="${(t.name || '').replace(/"/g, '"')}">${(t.name || '')} (${t.type || ""} / ${t.role || ""})</option>`
|
||||
)
|
||||
.join("");
|
||||
log("已加载现有设备列表,可从下拉框选择后补充 GPS。");
|
||||
} catch (e) {
|
||||
log("加载现有设备失败:" + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
existingSelect.onchange = () => {
|
||||
const name = existingSelect.value;
|
||||
if (!name) {
|
||||
const lat = document.getElementById("lat").value;
|
||||
const lon = document.getElementById("lon").value;
|
||||
fillFormFromTarget({
|
||||
type: "topology",
|
||||
role: "other",
|
||||
lat,
|
||||
lon,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const t = existingTargets.find((r) => r.name === name);
|
||||
if (!t) return;
|
||||
fillFormFromTarget(t);
|
||||
};
|
||||
|
||||
document.getElementById("btn-gps").onclick = () => {
|
||||
if (!navigator.geolocation) {
|
||||
log("当前浏览器不支持 Geolocation。");
|
||||
return;
|
||||
}
|
||||
log("正在获取 GPS 坐标…");
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(pos) => {
|
||||
const { latitude, longitude, accuracy } = pos.coords;
|
||||
document.getElementById("lat").value = latitude.toFixed(6);
|
||||
document.getElementById("lon").value = longitude.toFixed(6);
|
||||
lastGpsAccuracyM = accuracy != null ? accuracy : null;
|
||||
updateMapMarker(latitude, longitude);
|
||||
var acc = lastGpsAccuracyM != null ? ",精度约 " + Math.round(lastGpsAccuracyM) + " 米" : "";
|
||||
log("获取成功:lat=" + latitude + ", lon=" + longitude + acc + "。请在地图上核对位置,若有偏差可点击地图修正。");
|
||||
},
|
||||
(err) => {
|
||||
var msg = err.message || "";
|
||||
if (msg.indexOf("secure origins") !== -1 || msg.indexOf("secure context") !== -1) {
|
||||
log("获取定位失败:当前页面不是安全来源,浏览器不允许获取定位。请使用 https:// 访问本页,或在同一台电脑上用 http://localhost:4080 打开。");
|
||||
} else {
|
||||
log("获取定位失败:" + msg);
|
||||
}
|
||||
},
|
||||
{
|
||||
enableHighAccuracy: true,
|
||||
timeout: 10000,
|
||||
maximumAge: 0,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
document.getElementById("btn-load-map").onclick = loadTiandituMap;
|
||||
|
||||
document.getElementById("btn-load-map-cache").onclick = loadLeafletThenInitCacheMap;
|
||||
|
||||
document.getElementById("btn-upload").onclick = async () => {
|
||||
var fileInput = document.getElementById("csv-file");
|
||||
if (!fileInput.files || !fileInput.files[0]) {
|
||||
log("请先选择要上传的 CSV 文件。");
|
||||
return;
|
||||
}
|
||||
var form = new FormData();
|
||||
form.append("file", fileInput.files[0]);
|
||||
try {
|
||||
log("正在上传…");
|
||||
var r = await fetch("/api/upload", { method: "POST", body: form });
|
||||
var d = await r.json();
|
||||
if (!r.ok) throw new Error(d.error || "上传失败");
|
||||
log("已上传,共 " + (d.rows || 0) + " 条。");
|
||||
loadExisting();
|
||||
} catch (e) {
|
||||
log("上传失败:" + e.message);
|
||||
}
|
||||
};
|
||||
|
||||
(async function setModeHint() {
|
||||
try {
|
||||
var r = await fetch("/api/mode");
|
||||
var d = await r.json();
|
||||
var el = document.getElementById("mode-hint");
|
||||
el.textContent = d.mode === "file" ? "当前为「文件模式」:直接读写边缘 config/targets.csv,保存后自动执行脚本。" : "当前为「内存模式」:请先上传 targets.csv,编辑后可下载到本机再部署到边缘。";
|
||||
} catch (e) {}
|
||||
})();
|
||||
|
||||
(async function setMapConfig() {
|
||||
try {
|
||||
var r = await fetch("/api/map-config");
|
||||
var d = await r.json();
|
||||
if (d.cacheBaseUrl) {
|
||||
cacheBaseUrl = d.cacheBaseUrl;
|
||||
document.getElementById("cache-buttons").style.display = "inline";
|
||||
}
|
||||
} catch (e) {}
|
||||
})();
|
||||
|
||||
(function () {
|
||||
try {
|
||||
var saved = localStorage.getItem("tianditu_tk");
|
||||
if (saved) document.getElementById("tianditu-tk").value = saved;
|
||||
} catch (e) {}
|
||||
})();
|
||||
|
||||
document.getElementById("btn-save").onclick = async () => {
|
||||
const payload = {
|
||||
type: document.getElementById("type").value,
|
||||
ip: document.getElementById("ip").value.trim(),
|
||||
name: document.getElementById("name").value.trim(),
|
||||
role: document.getElementById("role").value,
|
||||
parent: document.getElementById("parent").value.trim(),
|
||||
uplink_type: document.getElementById("uplink_type").value,
|
||||
location: document.getElementById("location").value.trim(),
|
||||
lat: document.getElementById("lat").value.trim(),
|
||||
lon: document.getElementById("lon").value.trim(),
|
||||
};
|
||||
|
||||
if (!payload.name || !payload.type) {
|
||||
log("type 与 name 为必填。");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
log("正在保存并重建配置…");
|
||||
const resp = await fetch("/api/targets", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (!resp.ok) {
|
||||
throw new Error(data.error || "请求失败");
|
||||
}
|
||||
log("已写入 targets.csv,并触发 update-configs.sh。");
|
||||
loadExisting();
|
||||
} catch (e) {
|
||||
log("保存失败:" + e.message);
|
||||
}
|
||||
};
|
||||
|
||||
loadExisting();
|
||||
</script>
|
||||
267
central-server/apps/topology-editor/server.js
Normal file
267
central-server/apps/topology-editor/server.js
Normal file
@@ -0,0 +1,267 @@
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const { exec } = require('child_process');
|
||||
const multer = require('multer');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 4080;
|
||||
const TILE_CACHE_URL = (process.env.TILE_CACHE_URL || '').trim();
|
||||
|
||||
const ROOT_DIR = path.join(__dirname, '..');
|
||||
const CONFIG_DIR = process.env.CONFIG_DIR || null;
|
||||
const TARGETS_CSV = CONFIG_DIR ? path.join(CONFIG_DIR, 'targets.csv') : null;
|
||||
|
||||
const upload = multer({ storage: multer.memoryStorage() });
|
||||
|
||||
// 内存模式(与 central-server 一起跑、无挂载时):存一份 targets 的解析结果
|
||||
const DEFAULT_HEADER = ['type', 'ip', 'name', 'role', 'parent', 'uplink_type', 'network', 'device_type', 'model', 'location', 'username', 'password', 'onvif_port', 'lat', 'lon'];
|
||||
let memoryStore = {
|
||||
comments: ['# 统一监控 + 拓扑目标配置文件\n', '# 格式: type,ip,name,role,parent,uplink_type,...\n'],
|
||||
header: DEFAULT_HEADER,
|
||||
rows: [],
|
||||
};
|
||||
|
||||
function isFileMode() {
|
||||
return CONFIG_DIR && TARGETS_CSV && fs.existsSync(TARGETS_CSV);
|
||||
}
|
||||
|
||||
app.use(express.json());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
function parseCsv(text) {
|
||||
const lines = text.split(/\r?\n/);
|
||||
const comments = [];
|
||||
let headerLineIndex = -1;
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i].trim();
|
||||
if (!line || line.startsWith('#')) {
|
||||
comments.push(lines[i]);
|
||||
continue;
|
||||
}
|
||||
headerLineIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (headerLineIndex === -1) {
|
||||
return { comments: lines, header: DEFAULT_HEADER, rows: [] };
|
||||
}
|
||||
|
||||
const header = lines[headerLineIndex].split(',').map(s => s.trim());
|
||||
const rows = [];
|
||||
|
||||
for (let i = headerLineIndex + 1; i < lines.length; i++) {
|
||||
const raw = lines[i];
|
||||
if (!raw || raw.trim().startsWith('#')) continue;
|
||||
const parts = raw.split(',');
|
||||
const obj = {};
|
||||
header.forEach((h, idx) => {
|
||||
obj[h] = (parts[idx] || '').trim();
|
||||
});
|
||||
if (Object.values(obj).every(v => v === '')) continue;
|
||||
rows.push(obj);
|
||||
}
|
||||
|
||||
return { comments, header, rows };
|
||||
}
|
||||
|
||||
function stringifyCsv(comments, header, rows) {
|
||||
const lines = [];
|
||||
if (comments && comments.length) {
|
||||
lines.push(...comments);
|
||||
}
|
||||
if (header && header.length) {
|
||||
lines.push(header.join(','));
|
||||
}
|
||||
for (const row of rows) {
|
||||
const line = header.map(h => (row[h] || '').replace(/,/g, ' ')).join(',');
|
||||
lines.push(line);
|
||||
}
|
||||
return lines.join('\n') + '\n';
|
||||
}
|
||||
|
||||
function loadTargets() {
|
||||
if (isFileMode()) {
|
||||
const text = fs.readFileSync(TARGETS_CSV, 'utf8');
|
||||
return parseCsv(text);
|
||||
}
|
||||
return { ...memoryStore, rows: [...memoryStore.rows] };
|
||||
}
|
||||
|
||||
function saveTargets(parsed) {
|
||||
if (isFileMode()) {
|
||||
const text = stringifyCsv(parsed.comments, parsed.header, parsed.rows);
|
||||
fs.writeFileSync(TARGETS_CSV, text, 'utf8');
|
||||
return;
|
||||
}
|
||||
memoryStore = {
|
||||
comments: parsed.comments || memoryStore.comments,
|
||||
header: parsed.header || memoryStore.header,
|
||||
rows: parsed.rows || memoryStore.rows,
|
||||
};
|
||||
}
|
||||
|
||||
function rebuildConfigs() {
|
||||
if (!CONFIG_DIR) return;
|
||||
const cmd = `cd "${CONFIG_DIR}" && ./update-configs.sh`;
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.error('重建配置失败:', err.message);
|
||||
if (stderr) console.error(stderr);
|
||||
return;
|
||||
}
|
||||
if (stdout) console.log(stdout);
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/api/targets', (req, res) => {
|
||||
try {
|
||||
const parsed = loadTargets();
|
||||
res.json(parsed.rows);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
res.status(500).json({ error: '读取 targets 失败' });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/mode', (req, res) => {
|
||||
res.json({ mode: isFileMode() ? 'file' : 'memory' });
|
||||
});
|
||||
|
||||
app.get('/api/map-config', (req, res) => {
|
||||
res.json({ cacheBaseUrl: TILE_CACHE_URL ? '/tiles' : '' });
|
||||
});
|
||||
|
||||
function proxyToTileCache(pathname, res) {
|
||||
const url = TILE_CACHE_URL + pathname;
|
||||
const u = new URL(url);
|
||||
const client = u.protocol === 'https:' ? require('https') : require('http');
|
||||
client.get(url, (proxyRes) => {
|
||||
res.status(proxyRes.statusCode || 200);
|
||||
if (proxyRes.headers['content-type']) res.setHeader('Content-Type', proxyRes.headers['content-type']);
|
||||
if (proxyRes.headers['cache-control']) res.setHeader('Cache-Control', proxyRes.headers['cache-control']);
|
||||
proxyRes.pipe(res);
|
||||
}).on('error', (err) => {
|
||||
res.status(502).json({ error: 'Tile cache unreachable: ' + err.message });
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/tiles/vec/:z/:x/:y', (req, res) => {
|
||||
if (!TILE_CACHE_URL) return res.status(503).send('Tile cache not configured');
|
||||
proxyToTileCache(`/vec/${req.params.z}/${req.params.x}/${req.params.y}`, res);
|
||||
});
|
||||
|
||||
app.get('/tiles/cva/:z/:x/:y', (req, res) => {
|
||||
if (!TILE_CACHE_URL) return res.status(503).send('Tile cache not configured');
|
||||
proxyToTileCache(`/cva/${req.params.z}/${req.params.x}/${req.params.y}`, res);
|
||||
});
|
||||
|
||||
app.get('/api/download', (req, res) => {
|
||||
try {
|
||||
const parsed = loadTargets();
|
||||
const text = stringifyCsv(parsed.comments, parsed.header, parsed.rows);
|
||||
res.setHeader('Content-Type', 'text/csv; charset=utf-8');
|
||||
res.setHeader('Content-Disposition', 'attachment; filename=targets.csv');
|
||||
res.send(text);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
res.status(500).json({ error: '生成下载失败' });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/upload', upload.single('file'), (req, res) => {
|
||||
try {
|
||||
if (!req.file || !req.file.buffer) {
|
||||
return res.status(400).json({ error: '请选择 CSV 文件上传' });
|
||||
}
|
||||
const text = req.file.buffer.toString('utf8');
|
||||
const parsed = parseCsv(text);
|
||||
if (!isFileMode()) {
|
||||
memoryStore = parsed;
|
||||
} else {
|
||||
saveTargets(parsed);
|
||||
}
|
||||
res.json({ ok: true, rows: parsed.rows.length });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
res.status(500).json({ error: '解析 CSV 失败' });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/targets', (req, res) => {
|
||||
try {
|
||||
const {
|
||||
type = '',
|
||||
ip = '',
|
||||
name = '',
|
||||
role = '',
|
||||
parent = '',
|
||||
uplink_type = '',
|
||||
network = '',
|
||||
device_type = '',
|
||||
model = '',
|
||||
location = '',
|
||||
username = '',
|
||||
password = '',
|
||||
onvif_port = '',
|
||||
lat = '',
|
||||
lon = '',
|
||||
} = req.body || {};
|
||||
|
||||
if (!type || !name) {
|
||||
return res.status(400).json({ error: 'type 与 name 为必填字段' });
|
||||
}
|
||||
|
||||
const parsed = loadTargets();
|
||||
const { header, rows } = parsed;
|
||||
|
||||
const idx = rows.findIndex((r) => r.name === name);
|
||||
const row = {};
|
||||
header.forEach((h) => {
|
||||
row[h] = '';
|
||||
});
|
||||
|
||||
Object.assign(row, {
|
||||
type,
|
||||
ip,
|
||||
name,
|
||||
role,
|
||||
parent,
|
||||
uplink_type,
|
||||
network,
|
||||
device_type,
|
||||
model,
|
||||
location,
|
||||
username,
|
||||
password,
|
||||
onvif_port,
|
||||
lat,
|
||||
lon,
|
||||
});
|
||||
|
||||
if (idx >= 0) {
|
||||
rows[idx] = row;
|
||||
} else {
|
||||
rows.push(row);
|
||||
}
|
||||
|
||||
saveTargets({ ...parsed, rows });
|
||||
rebuildConfigs();
|
||||
|
||||
res.json({ ok: true, row });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
res.status(500).json({ error: '写入失败' });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Topology editor listening on http://0.0.0.0:${PORT}`);
|
||||
if (CONFIG_DIR) {
|
||||
console.log(`CONFIG_DIR=${CONFIG_DIR} (file mode)`);
|
||||
} else {
|
||||
console.log('Running in memory mode: use Upload CSV / Download CSV');
|
||||
}
|
||||
});
|
||||
@@ -1,10 +1,25 @@
|
||||
# Prometheus 中央服务器配置模板
|
||||
# ============================================
|
||||
# 说明:
|
||||
# - 本文件为配置模板,包含 ${变量名} 占位符
|
||||
# - 部署时由 deploy.sh 从 .env 读取变量,用 envsubst 生成 prometheus.yml
|
||||
# - 请勿直接编辑 prometheus.yml,修改应在此模板或 .env 中进行
|
||||
#
|
||||
# 变量来源:central-server/.env(参考 env.example);本文件位于 config/prometheus/
|
||||
# 涉及变量:PROMETHEUS_SCRAPE_INTERVAL, PROMETHEUS_EVALUATION_INTERVAL,
|
||||
# PROMETHEUS_CLUSTER_NAME, VICTORIAMETRICS_PORT,
|
||||
# PROMETHEUS_REMOTE_WRITE_MAX_SAMPLES, PROMETHEUS_REMOTE_WRITE_CAPACITY,
|
||||
# PROMETHEUS_REMOTE_WRITE_MAX_SHARDS
|
||||
# ============================================
|
||||
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
cluster: 'central-monitoring'
|
||||
|
||||
# 远程写入配置 - 接收来自边缘节点的数据
|
||||
# 远程写入:将中央 Prometheus 抓取到的本地服务指标推送到 VictoriaMetrics
|
||||
# (边缘节点由 vmagent 直接 remote_write 到 VictoriaMetrics)
|
||||
remote_write:
|
||||
- url: http://victoria-metrics:8428/api/v1/write
|
||||
queue_config:
|
||||
@@ -12,7 +27,7 @@ remote_write:
|
||||
capacity: 20000
|
||||
max_shards: 10
|
||||
|
||||
# 抓取配置 - 主要抓取本地服务
|
||||
# 抓取配置:仅抓取中央本机 Docker 容器(Prometheus/VM/Alertmanager/Grafana)
|
||||
scrape_configs:
|
||||
# 抓取中央Prometheus自身
|
||||
- job_name: 'prometheus-central'
|
||||
@@ -40,11 +55,11 @@ scrape_configs:
|
||||
static_configs:
|
||||
- targets: ['grafana:3000']
|
||||
|
||||
# 告警规则配置
|
||||
# 告警规则:alert_rules.yml 与 prometheus.yml 同目录
|
||||
rule_files:
|
||||
- "alert_rules.yml"
|
||||
|
||||
# Alertmanager配置
|
||||
# Alertmanager:告警路由与静默
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- static_configs:
|
||||
@@ -1,10 +1,25 @@
|
||||
# Prometheus 中央服务器配置模板
|
||||
# ============================================
|
||||
# 说明:
|
||||
# - 本文件为配置模板,包含 ${变量名} 占位符
|
||||
# - 部署时由 deploy.sh 从 .env 读取变量,用 envsubst 生成 prometheus.yml
|
||||
# - 请勿直接编辑 prometheus.yml,修改应在此模板或 .env 中进行
|
||||
#
|
||||
# 变量来源:central-server/.env(参考 env.example);本文件位于 config/prometheus/
|
||||
# 涉及变量:PROMETHEUS_SCRAPE_INTERVAL, PROMETHEUS_EVALUATION_INTERVAL,
|
||||
# PROMETHEUS_CLUSTER_NAME, VICTORIAMETRICS_PORT,
|
||||
# PROMETHEUS_REMOTE_WRITE_MAX_SAMPLES, PROMETHEUS_REMOTE_WRITE_CAPACITY,
|
||||
# PROMETHEUS_REMOTE_WRITE_MAX_SHARDS
|
||||
# ============================================
|
||||
|
||||
global:
|
||||
scrape_interval: ${PROMETHEUS_SCRAPE_INTERVAL}s
|
||||
evaluation_interval: ${PROMETHEUS_EVALUATION_INTERVAL}s
|
||||
external_labels:
|
||||
cluster: '${PROMETHEUS_CLUSTER_NAME}'
|
||||
|
||||
# 远程写入配置 - 接收来自边缘节点的数据
|
||||
# 远程写入:将中央 Prometheus 抓取到的本地服务指标推送到 VictoriaMetrics
|
||||
# (边缘节点由 vmagent 直接 remote_write 到 VictoriaMetrics)
|
||||
remote_write:
|
||||
- url: http://victoria-metrics:${VICTORIAMETRICS_PORT}/api/v1/write
|
||||
queue_config:
|
||||
@@ -12,7 +27,7 @@ remote_write:
|
||||
capacity: ${PROMETHEUS_REMOTE_WRITE_CAPACITY}
|
||||
max_shards: ${PROMETHEUS_REMOTE_WRITE_MAX_SHARDS}
|
||||
|
||||
# 抓取配置 - 主要抓取本地服务
|
||||
# 抓取配置:仅抓取中央本机 Docker 容器(Prometheus/VM/Alertmanager/Grafana)
|
||||
scrape_configs:
|
||||
# 抓取中央Prometheus自身
|
||||
- job_name: 'prometheus-central'
|
||||
@@ -40,11 +55,11 @@ scrape_configs:
|
||||
static_configs:
|
||||
- targets: ['grafana:3000']
|
||||
|
||||
# 告警规则配置
|
||||
# 告警规则:alert_rules.yml 与 prometheus.yml 同目录
|
||||
rule_files:
|
||||
- "alert_rules.yml"
|
||||
|
||||
# Alertmanager配置
|
||||
# Alertmanager:告警路由与静默
|
||||
alerting:
|
||||
alertmanagers:
|
||||
- static_configs:
|
||||
@@ -45,6 +45,36 @@ PROMETHEUS_REMOTE_WRITE_CAPACITY=${PROMETHEUS_REMOTE_WRITE_CAPACITY:-20000}
|
||||
PROMETHEUS_REMOTE_WRITE_MAX_SHARDS=${PROMETHEUS_REMOTE_WRITE_MAX_SHARDS:-10}
|
||||
GRAFANA_DEFAULT_LANGUAGE=${GRAFANA_DEFAULT_LANGUAGE:-zh-Hans}
|
||||
GRAFANA_DEFAULT_THEME=${GRAFANA_DEFAULT_THEME:-light}
|
||||
TRAEFIK_PROVIDER=${TRAEFIK_PROVIDER:-external}
|
||||
|
||||
# 根据 TRAEFIK_ENABLED 与 TRAEFIK_PROVIDER 设置网络
|
||||
if [ "${TRAEFIK_ENABLED:-false}" = "true" ]; then
|
||||
case "${TRAEFIK_PROVIDER}" in
|
||||
internal)
|
||||
export NETWORK_NAME=${NETWORK_NAME:-central_default}
|
||||
export EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-false}
|
||||
export TRAEFIK_NETWORK=${TRAEFIK_NETWORK:-central_default}
|
||||
export COMPOSE_PROFILES="${COMPOSE_PROFILES:-},traefik-internal"
|
||||
export COMPOSE_PROFILES="${COMPOSE_PROFILES#,}"
|
||||
;;
|
||||
external)
|
||||
export NETWORK_NAME=${NETWORK_NAME:-traefik}
|
||||
export EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-true}
|
||||
export TRAEFIK_NETWORK=${TRAEFIK_NETWORK:-traefik}
|
||||
;;
|
||||
*)
|
||||
echo "⚠️ TRAEFIK_PROVIDER 应为 internal 或 external,当前为 ${TRAEFIK_PROVIDER}"
|
||||
export NETWORK_NAME=${NETWORK_NAME:-traefik}
|
||||
export EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-true}
|
||||
export TRAEFIK_NETWORK=${TRAEFIK_NETWORK:-traefik}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# 不使用 Traefik:使用 compose 默认网络,直连端口访问
|
||||
export NETWORK_NAME=${NETWORK_NAME:-central_default}
|
||||
export EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-false}
|
||||
export TRAEFIK_NETWORK=${TRAEFIK_NETWORK:-central_default}
|
||||
fi
|
||||
|
||||
# 将相对路径转换为绝对路径(Docker 需要绝对路径)
|
||||
# 获取脚本所在目录的绝对路径
|
||||
@@ -140,12 +170,12 @@ fi
|
||||
echo ""
|
||||
|
||||
# 从模板生成 prometheus.yml
|
||||
if [ -f "prometheus.yml.template" ]; then
|
||||
echo "📝 从模板生成 prometheus.yml..."
|
||||
if [ -f "config/prometheus/prometheus.yml.template" ]; then
|
||||
echo "📝 从模板生成 config/prometheus/prometheus.yml..."
|
||||
# 检查是否有 envsubst 命令
|
||||
if command -v envsubst &> /dev/null; then
|
||||
envsubst < prometheus.yml.template > prometheus.yml
|
||||
echo "✅ prometheus.yml 已生成"
|
||||
envsubst < config/prometheus/prometheus.yml.template > config/prometheus/prometheus.yml
|
||||
echo "✅ config/prometheus/prometheus.yml 已生成"
|
||||
else
|
||||
echo "⚠️ envsubst 命令未找到,尝试使用 sed 替换..."
|
||||
# 使用 sed 进行简单的变量替换
|
||||
@@ -156,22 +186,22 @@ if [ -f "prometheus.yml.template" ]; then
|
||||
-e "s/\${PROMETHEUS_REMOTE_WRITE_MAX_SAMPLES}/${PROMETHEUS_REMOTE_WRITE_MAX_SAMPLES}/g" \
|
||||
-e "s/\${PROMETHEUS_REMOTE_WRITE_CAPACITY}/${PROMETHEUS_REMOTE_WRITE_CAPACITY}/g" \
|
||||
-e "s/\${PROMETHEUS_REMOTE_WRITE_MAX_SHARDS}/${PROMETHEUS_REMOTE_WRITE_MAX_SHARDS}/g" \
|
||||
prometheus.yml.template > prometheus.yml
|
||||
echo "✅ prometheus.yml 已生成(使用 sed)"
|
||||
config/prometheus/prometheus.yml.template > config/prometheus/prometheus.yml
|
||||
echo "✅ config/prometheus/prometheus.yml 已生成(使用 sed)"
|
||||
fi
|
||||
elif [ ! -f "prometheus.yml" ]; then
|
||||
echo "❌ 配置文件 prometheus.yml 不存在,且未找到模板文件"
|
||||
elif [ ! -f "config/prometheus/prometheus.yml" ]; then
|
||||
echo "❌ 配置文件 config/prometheus/prometheus.yml 不存在,且未找到模板文件"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查配置文件
|
||||
if [ ! -f "alert_rules.yml" ]; then
|
||||
echo "❌ 配置文件 alert_rules.yml 不存在"
|
||||
if [ ! -f "config/prometheus/alert_rules.yml" ]; then
|
||||
echo "❌ 配置文件 config/prometheus/alert_rules.yml 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "alertmanager/alertmanager.yml" ]; then
|
||||
echo "❌ 配置文件 alertmanager/alertmanager.yml 不存在"
|
||||
if [ ! -f "config/alertmanager/alertmanager.yml" ]; then
|
||||
echo "❌ 配置文件 config/alertmanager/alertmanager.yml 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -199,18 +229,23 @@ export GRAFANA_DOMAIN
|
||||
export PROMETHEUS_DOMAIN
|
||||
export ALERTMANAGER_DOMAIN
|
||||
|
||||
# 检查 Traefik 网络(docker-compose.yml 中总是会引用此网络,无论是否启用)
|
||||
# 检查 Traefik 网络(仅 TRAEFIK_PROVIDER=external 时需已存在)
|
||||
echo "🔍 检查 Traefik 网络..."
|
||||
TRAEFIK_NET=${TRAEFIK_NETWORK:-traefik}
|
||||
if ! docker network inspect "$TRAEFIK_NET" &> /dev/null; then
|
||||
if [ "${TRAEFIK_ENABLED:-false}" != "true" ]; then
|
||||
echo "✅ 未启用 Traefik,使用 compose 默认网络"
|
||||
elif [ "${TRAEFIK_PROVIDER}" = "internal" ]; then
|
||||
echo "✅ 本编排启动 Traefik,将自动创建网络 $TRAEFIK_NET"
|
||||
elif ! docker network inspect "$TRAEFIK_NET" &> /dev/null; then
|
||||
echo "⚠️ Traefik 网络 '$TRAEFIK_NET' 不存在,正在创建..."
|
||||
if docker network create "$TRAEFIK_NET" 2>/dev/null; then
|
||||
echo "✅ Traefik 网络 '$TRAEFIK_NET' 已创建"
|
||||
else
|
||||
echo "❌ 无法创建 Traefik 网络 '$TRAEFIK_NET'"
|
||||
echo " 请确保:"
|
||||
echo " 1. Traefik 已运行并创建了网络"
|
||||
echo " 2. 或手动创建网络: docker network create $TRAEFIK_NET"
|
||||
echo " 1. 外部 Traefik 已运行并创建了网络"
|
||||
echo " 2. 或改为 TRAEFIK_PROVIDER=internal 由本编排启动 Traefik"
|
||||
echo " 3. 或手动创建网络: docker network create $TRAEFIK_NET"
|
||||
echo ""
|
||||
read -p "是否继续部署?(y/N): " -n 1 -r
|
||||
echo
|
||||
@@ -220,7 +255,7 @@ if ! docker network inspect "$TRAEFIK_NET" &> /dev/null; then
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "✅ Traefik 网络 '$TRAEFIK_NET' 已存在"
|
||||
echo "✅ Traefik 网络 '$TRAEFIK_NET' 已存在(外部 Traefik)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
@@ -229,9 +264,9 @@ echo "📁 创建数据目录..."
|
||||
mkdir -p "${PROMETHEUS_DATA_DIR}"
|
||||
mkdir -p "${GRAFANA_DATA_DIR}"
|
||||
mkdir -p "${VICTORIAMETRICS_DATA_DIR}"
|
||||
mkdir -p grafana/dashboards
|
||||
mkdir -p grafana/provisioning/datasources
|
||||
mkdir -p grafana/provisioning/dashboards
|
||||
mkdir -p config/grafana/dashboards
|
||||
mkdir -p config/grafana/provisioning/datasources
|
||||
mkdir -p config/grafana/provisioning/dashboards
|
||||
|
||||
# 设置目录权限
|
||||
# Prometheus 需要写权限
|
||||
@@ -293,15 +328,17 @@ echo ""
|
||||
# 检查是否启用 Traefik
|
||||
if [ "${TRAEFIK_ENABLED:-false}" = "true" ]; then
|
||||
echo "🔗 访问地址(通过 Traefik 反向代理):"
|
||||
if [ "${TRAEFIK_PROVIDER}" = "internal" ]; then
|
||||
echo " - Traefik 由本编排启动,监听 80/443 端口"
|
||||
fi
|
||||
echo " - Grafana仪表板: http://${GRAFANA_DOMAIN:-grafana.example.com} (admin/${GRAFANA_ADMIN_PASSWORD}) [${GRAFANA_DEFAULT_LANGUAGE}界面]"
|
||||
echo " - Prometheus: http://${PROMETHEUS_DOMAIN:-prometheus.example.com} [英文界面]"
|
||||
echo " - Alertmanager: http://${ALERTMANAGER_DOMAIN:-alertmanager.example.com} [英文界面]"
|
||||
echo " - VictoriaMetrics: http://localhost:${VICTORIAMETRICS_PORT} [英文界面,边缘节点直接连接]"
|
||||
echo ""
|
||||
echo "⚠️ 请确保:"
|
||||
echo " 1. DNS 已正确解析域名到 Traefik 服务器"
|
||||
echo " 2. Traefik 网络 (${TRAEFIK_NETWORK:-traefik_default}) 已创建"
|
||||
echo " 3. 边缘节点可以访问此服务器的${VICTORIAMETRICS_PORT}端口(VictoriaMetrics 不通过 Traefik)"
|
||||
echo " 1. DNS 已正确解析域名到本机"
|
||||
echo " 2. 边缘节点可以访问此服务器的${VICTORIAMETRICS_PORT}端口(VictoriaMetrics 不通过 Traefik)"
|
||||
else
|
||||
echo "🔗 访问地址:"
|
||||
echo " - Grafana仪表板: http://localhost:${GRAFANA_PORT} (admin/${GRAFANA_ADMIN_PASSWORD}) [${GRAFANA_DEFAULT_LANGUAGE}界面]"
|
||||
|
||||
@@ -4,12 +4,13 @@ services:
|
||||
image: prom/prometheus:latest
|
||||
container_name: prometheus-central
|
||||
restart: unless-stopped
|
||||
mem_limit: "128m"
|
||||
ports:
|
||||
- "${PROMETHEUS_PORT:-9091}:9090"
|
||||
volumes:
|
||||
- ${PROMETHEUS_DATA_DIR:-./data/prometheus-data}:/prometheus
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- ./alert_rules.yml:/etc/prometheus/alert_rules.yml:ro
|
||||
- ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- ./config/prometheus/alert_rules.yml:/etc/prometheus/alert_rules.yml:ro
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- "--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_TIME:-30d}"
|
||||
@@ -29,6 +30,7 @@ services:
|
||||
image: grafana/grafana:latest
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
mem_limit: "128m"
|
||||
ports:
|
||||
- "${GRAFANA_PORT:-3000}:3000"
|
||||
environment:
|
||||
@@ -41,8 +43,8 @@ services:
|
||||
- GF_SERVER_ROOT_URL=${GRAFANA_ROOT_URL:-http://localhost:3000}
|
||||
volumes:
|
||||
- ${GRAFANA_DATA_DIR:-./data/grafana-data}:/var/lib/grafana
|
||||
- ./grafana/provisioning:/etc/grafana/provisioning
|
||||
- ./grafana/dashboards:/var/lib/grafana/dashboards
|
||||
- ./config/grafana/provisioning:/etc/grafana/provisioning
|
||||
- ./config/grafana/dashboards:/var/lib/grafana/dashboards
|
||||
labels:
|
||||
- "traefik.enable=${TRAEFIK_ENABLED:-true}"
|
||||
- "traefik.http.routers.grafana.rule=Host(`${GRAFANA_DOMAIN:-grafana.example.com}`)"
|
||||
@@ -56,10 +58,11 @@ services:
|
||||
image: prom/alertmanager:latest
|
||||
container_name: alertmanager
|
||||
restart: unless-stopped
|
||||
mem_limit: "32m"
|
||||
ports:
|
||||
- "${ALERTMANAGER_PORT:-9093}:9093"
|
||||
volumes:
|
||||
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
|
||||
- ./config/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
|
||||
labels:
|
||||
- "traefik.enable=${TRAEFIK_ENABLED:-true}"
|
||||
- "traefik.http.routers.alertmanager.rule=Host(`${ALERTMANAGER_DOMAIN:-alertmanager.example.com}`)"
|
||||
@@ -73,6 +76,7 @@ services:
|
||||
image: victoriametrics/victoria-metrics:latest
|
||||
container_name: victoria-metrics
|
||||
restart: unless-stopped
|
||||
mem_limit: "64m"
|
||||
ports:
|
||||
- "${VICTORIAMETRICS_PORT:-8428}:8428"
|
||||
volumes:
|
||||
@@ -82,11 +86,47 @@ services:
|
||||
- "--retentionPeriod=${VICTORIAMETRICS_RETENTION_PERIOD:-30d}"
|
||||
- "--httpListenAddr=:${VICTORIAMETRICS_PORT:-8428}"
|
||||
|
||||
# GPS 标注助手(上传/下载 targets.csv,H5 采集 GPS + 天地图校验)
|
||||
topology-editor:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: apps/topology-editor/Dockerfile
|
||||
image: topology-editor:local
|
||||
container_name: topology-editor
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- PORT=4080
|
||||
- TILE_CACHE_URL=http://tile-cache:4090
|
||||
ports:
|
||||
- "${TOPOLOGY_EDITOR_PORT:-4080}:4080"
|
||||
mem_limit: "128m"
|
||||
|
||||
# Traefik 反向代理(仅 TRAEFIK_PROVIDER=internal 时启动)
|
||||
traefik:
|
||||
image: traefik:v2.10
|
||||
container_name: traefik-central
|
||||
restart: unless-stopped
|
||||
profiles:
|
||||
- traefik-internal
|
||||
command:
|
||||
- "--api.insecure=true"
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--providers.docker.network=${TRAEFIK_NETWORK:-central_default}"
|
||||
- "--entrypoints.web.address=:80"
|
||||
- "--entrypoints.websecure.address=:443"
|
||||
ports:
|
||||
- "${TRAEFIK_HTTP_PORT:-80}:80"
|
||||
- "${TRAEFIK_HTTPS_PORT:-443}:443"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
mem_limit: "64m"
|
||||
|
||||
# 天地图瓦片缓存(节省 key 免费量;可手动清空缓存后重新拉取)
|
||||
tile-cache:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: tile-cache/Dockerfile
|
||||
context: .
|
||||
dockerfile: apps/tile-cache/Dockerfile
|
||||
image: tile-cache:local
|
||||
container_name: tile-cache
|
||||
restart: unless-stopped
|
||||
@@ -100,7 +140,7 @@ services:
|
||||
- ${TILE_CACHE_DATA_DIR:-./data/tile-cache}:/cache
|
||||
ports:
|
||||
- "${TILE_CACHE_PORT:-4090}:4090"
|
||||
mem_limit: "128m"
|
||||
mem_limit: "32m"
|
||||
|
||||
|
||||
# 定义网络配置(默认使用已存在的 traefik 网络)
|
||||
|
||||
@@ -1,55 +1,85 @@
|
||||
# 中央服务器环境变量配置
|
||||
# 复制此文件为 .env 并根据实际情况修改
|
||||
# =============================================================================
|
||||
# 中央服务器环境变量配置模板
|
||||
# =============================================================================
|
||||
#
|
||||
# 【用途】
|
||||
# 本文件为 central-server 所有可配置参数的模板,供 deploy.sh 和 docker-compose 使用。
|
||||
# 部署脚本 deploy.sh 会读取 .env,并将部分变量代入 prometheus.yml.template 生成 prometheus.yml。
|
||||
#
|
||||
# 【使用方式】
|
||||
# 1. 复制为 .env: cp env.example .env
|
||||
# 2. 编辑 .env,按实际环境修改参数
|
||||
# 3. 运行部署脚本: ./deploy.sh
|
||||
#
|
||||
# 若不存在 .env,deploy.sh 会自动从 env.example 创建,并提示修改后重试。
|
||||
#
|
||||
# 【变量去向】
|
||||
# - deploy.sh:加载 .env,生成 prometheus.yml,创建数据目录,启动 docker-compose
|
||||
# - docker-compose:端口、数据目录、容器环境变量、Traefik 标签等
|
||||
# - prometheus.yml.template:PROMETHEUS_*、VICTORIAMETRICS_PORT 等(见模板头部)
|
||||
#
|
||||
# 【修改生效】
|
||||
# 修改 .env 后需重新运行 ./deploy.sh。不要直接编辑 prometheus.yml,其由模板生成。
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
# ============================================
|
||||
# 端口配置
|
||||
# ============================================
|
||||
# 宿主机映射端口,对应各服务容器内端口。端口冲突时修改此处。
|
||||
|
||||
# Prometheus 端口(避免与 cockpit 冲突)
|
||||
# Prometheus Web UI 端口(避免与 cockpit 9090 冲突,故默认 9091)
|
||||
# 访问:http://localhost:${PROMETHEUS_PORT}
|
||||
PROMETHEUS_PORT=9091
|
||||
|
||||
# Grafana 端口
|
||||
# Grafana Web UI 端口
|
||||
# 访问:http://localhost:${GRAFANA_PORT}
|
||||
GRAFANA_PORT=3000
|
||||
|
||||
# Alertmanager 端口
|
||||
# Alertmanager Web UI 端口
|
||||
ALERTMANAGER_PORT=9093
|
||||
|
||||
# VictoriaMetrics 端口(边缘节点推送数据到此端口)
|
||||
# VictoriaMetrics 端口(边缘 vmagent 通过 remote_write 推送到此端口)
|
||||
# 必须与边缘侧 CENTRAL_VM_URL 中的端口一致;通常不通过 Traefik,边缘直连
|
||||
VICTORIAMETRICS_PORT=8428
|
||||
|
||||
# ============================================
|
||||
# Grafana 配置
|
||||
# ============================================
|
||||
|
||||
# Grafana 管理员密码
|
||||
# Grafana 管理员密码(生产环境必须修改,建议 12 位以上强密码)
|
||||
GRAFANA_ADMIN_PASSWORD=admin123
|
||||
|
||||
# Grafana 默认语言
|
||||
# Grafana 默认语言:zh-Hans 简体中文,en 英文
|
||||
GRAFANA_DEFAULT_LANGUAGE=zh-Hans
|
||||
|
||||
# Grafana 默认主题
|
||||
# Grafana 默认主题:light 浅色,dark 深色
|
||||
GRAFANA_DEFAULT_THEME=light
|
||||
|
||||
# Grafana 根 URL(用于 Traefik 反向代理,如果使用 Traefik,设置为 https://grafana.example.com)
|
||||
# Grafana 根 URL(使用 Traefik 时设为对外访问地址,如 https://grafana.example.com)
|
||||
# 影响登录跳转、OAuth 回调等
|
||||
GRAFANA_ROOT_URL=http://localhost:3000
|
||||
|
||||
# ============================================
|
||||
# Prometheus 配置
|
||||
# ============================================
|
||||
# 部分变量会代入 prometheus.yml.template 生成 prometheus.yml
|
||||
|
||||
# Prometheus 数据保留时间
|
||||
# Prometheus 本地 TSDB 数据保留时间(如 30d、7d、1y)
|
||||
PROMETHEUS_RETENTION_TIME=30d
|
||||
|
||||
# Prometheus 抓取间隔(秒)
|
||||
# 抓取间隔(秒),影响中央 Prometheus 抓取本机服务的频率
|
||||
# 建议 15–60;越小越实时,负载越高
|
||||
PROMETHEUS_SCRAPE_INTERVAL=15
|
||||
|
||||
# Prometheus 告警评估间隔(秒)
|
||||
# 告警规则评估间隔(秒)
|
||||
PROMETHEUS_EVALUATION_INTERVAL=15
|
||||
|
||||
# Prometheus 集群标识
|
||||
# 集群标识,作为 external_labels 中的 cluster 标签,用于区分多集群
|
||||
PROMETHEUS_CLUSTER_NAME=central-monitoring
|
||||
|
||||
# 远程写入队列配置
|
||||
# remote_write 到 VictoriaMetrics 的队列参数(中央 Prometheus 将抓取数据推送到 VM)
|
||||
# 边缘写入量大时可适当调大;一般保持默认即可
|
||||
PROMETHEUS_REMOTE_WRITE_MAX_SAMPLES=10000
|
||||
PROMETHEUS_REMOTE_WRITE_CAPACITY=20000
|
||||
PROMETHEUS_REMOTE_WRITE_MAX_SHARDS=10
|
||||
@@ -57,81 +87,83 @@ PROMETHEUS_REMOTE_WRITE_MAX_SHARDS=10
|
||||
# ============================================
|
||||
# VictoriaMetrics 配置
|
||||
# ============================================
|
||||
# VM 接收边缘 remote_write 并存储;Grafana 数据源通常指向 VM
|
||||
|
||||
# VictoriaMetrics 数据保留时间
|
||||
# VM 数据保留时间(如 30d、90d)
|
||||
VICTORIAMETRICS_RETENTION_PERIOD=30d
|
||||
|
||||
# ============================================
|
||||
# 数据存储路径
|
||||
# ============================================
|
||||
# 相对于 central-server 目录;deploy.sh 会转换为绝对路径供 Docker 使用
|
||||
|
||||
# 数据存储根目录(所有数据存储在此目录下,相对于 central-server 目录)
|
||||
# 使用相对路径,数据将存储在 central-server 目录下的 data 子目录中
|
||||
# 数据存储根目录(可选,部分脚本可能引用)
|
||||
DATA_STORAGE_ROOT=./data
|
||||
|
||||
# Prometheus 数据目录
|
||||
# Prometheus 本地 TSDB 数据目录
|
||||
PROMETHEUS_DATA_DIR=./data/prometheus-data
|
||||
|
||||
# Grafana 数据目录
|
||||
# Grafana 数据库与插件数据目录
|
||||
GRAFANA_DATA_DIR=./data/grafana-data
|
||||
|
||||
# VictoriaMetrics 数据目录
|
||||
# VictoriaMetrics 时序数据目录
|
||||
VICTORIAMETRICS_DATA_DIR=./data/victoria-metrics-data
|
||||
|
||||
# 天地图瓦片缓存(密钥与缓存参数均在 .env 中配置)
|
||||
# 在 .env 中设置 TIANDITU_TK 后,tile-cache 与拓扑助手「使用服务器缓存」、Grafana Geomap 方可使用天地图
|
||||
# 天地图瓦片缓存(供 topology-editor、Grafana Geomap 使用)
|
||||
# 在 .env 中设置 TIANDITU_TK 后,tile-cache 才可正常工作
|
||||
# TIANDITU_TK=您的天地图密钥
|
||||
# TILE_CACHE_PORT=4090
|
||||
# TILE_CACHE_DATA_DIR=./data/tile-cache
|
||||
# 缓存老化时间(天),超过后该瓦片下次请求时会重新向天地图拉取;默认 7,可改为 15 等
|
||||
# TILE_CACHE_TTL_DAYS=7
|
||||
# 向天地图请求单瓦片超时(毫秒),默认 15000;网络或上游慢时可适当调大
|
||||
# TILE_CACHE_UPSTREAM_TIMEOUT_MS=15000
|
||||
|
||||
# ============================================
|
||||
# Traefik 反向代理配置
|
||||
# ============================================
|
||||
# 启用后,docker-compose 会为各服务添加 Traefik 标签,通过域名访问
|
||||
|
||||
# 是否启用 Traefik 反向代理(true/false)
|
||||
# 如果启用,服务将通过 Traefik 访问,不再直接暴露端口
|
||||
# 是否启用 Traefik(true/false)。为 false 时通过宿主机端口直接访问
|
||||
TRAEFIK_ENABLED=true
|
||||
|
||||
# Traefik 网络名称(通常为 traefik)
|
||||
# Traefik 来源:internal=本编排启动 Traefik(包含 traefik 服务);external=使用已有外部 Traefik
|
||||
# internal:本 compose 内启动 Traefik,自动创建网络,无需外部 Traefik
|
||||
# external:接入已有 Traefik,需 traefik 网络已存在(如单独部署的 Traefik)
|
||||
TRAEFIK_PROVIDER=external
|
||||
|
||||
# Traefik 所在 Docker 网络名称
|
||||
# external 时通常为 traefik;internal 时为 central_default(compose 自动创建)
|
||||
TRAEFIK_NETWORK=traefik
|
||||
|
||||
# 域名配置(需要配置 DNS 解析到 Traefik 服务器)
|
||||
# Grafana 域名
|
||||
# 域名(需 DNS 解析到 Traefik 所在机器)
|
||||
GRAFANA_DOMAIN=grafana.example.com
|
||||
|
||||
# Prometheus 域名
|
||||
PROMETHEUS_DOMAIN=prometheus.example.com
|
||||
|
||||
# Alertmanager 域名
|
||||
ALERTMANAGER_DOMAIN=alertmanager.example.com
|
||||
|
||||
# VictoriaMetrics 域名(通常不需要通过 Traefik 访问,边缘节点直接连接)
|
||||
VICTORIAMETRICS_DOMAIN=vm.example.com
|
||||
|
||||
# Traefik EntryPoint(通常为 web 或 websecure)
|
||||
# Traefik EntryPoint(web=80, websecure=443)
|
||||
TRAEFIK_ENTRYPOINT=web
|
||||
|
||||
# 是否启用 HTTPS(需要配置 Traefik 的 TLS)
|
||||
# 是否启用 HTTPS(需 Traefik 配置 TLS)
|
||||
TRAEFIK_HTTPS_ENABLED=false
|
||||
|
||||
# TRAEFIK_PROVIDER=internal 时,Traefik 监听的宿主机端口
|
||||
# TRAEFIK_HTTP_PORT=80
|
||||
# TRAEFIK_HTTPS_PORT=443
|
||||
|
||||
# ============================================
|
||||
# Docker 网络配置
|
||||
# ============================================
|
||||
# 由 TRAEFIK_PROVIDER 决定;一般无需手动改,deploy.sh 会自动设置
|
||||
|
||||
# Compose 项目名称(用于区分同一目录下的多套部署,避免与旧状态冲突)
|
||||
# Compose 项目名称,用于区分同一目录多套部署
|
||||
COMPOSE_PROJECT_NAME=central
|
||||
|
||||
# 使用已存在的 traefik 网络(由 Traefik 创建,不在此项目中创建)
|
||||
# 保持以下两项即可接入现有 Traefik
|
||||
# TRAEFIK_PROVIDER=external 时:
|
||||
NETWORK_NAME=traefik
|
||||
EXTERNAL_NETWORK=true
|
||||
|
||||
# 仅在不使用 Traefik、仅本地直连时改为:
|
||||
# NETWORK_NAME=central-server_default
|
||||
# TRAEFIK_PROVIDER=internal 时(deploy.sh 会自动改为):
|
||||
# NETWORK_NAME=central_default
|
||||
# EXTERNAL_NETWORK=false
|
||||
|
||||
# 是否启用 IPv6(true/false)
|
||||
|
||||
Reference in New Issue
Block a user