diff --git a/README.md b/README.md index a4e69a5..8adf3af 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Gateway Checker +# DiAL 基于 Bun + TypeScript 的多类型拨测监控工具。通过 YAML 配置文件定义 HTTP 和命令行拨测目标,后端按配置定时并发拨测,结果持久化到本地 SQLite,前端 Dashboard 展示各目标实时状态、可用率、耗时趋势等。 @@ -233,12 +233,12 @@ bun run build 1. 运行 `vite build`,输出前端资源到 `dist/web` 2. 生成临时 `.build/static-assets.ts`,嵌入 Vite 产物 3. 生成临时 `.build/server-entry.ts`,作为生产入口 -4. 运行 `Bun.build({ compile })`,输出 `dist/gateway-checker` +4. 运行 `Bun.build({ compile })`,输出 `dist/dial-server` 运行 executable: ```bash -./dist/gateway-checker probes.yaml +./dist/dial-server probes.yaml ``` ## 运行参数 @@ -246,7 +246,7 @@ bun run build CLI 只接受一个参数:YAML 配置文件路径。 ```bash -./dist/gateway-checker ./probes.yaml +./dist/dial-server ./probes.yaml ``` ## 测试 diff --git a/openspec/specs/probe-config/spec.md b/openspec/specs/probe-config/spec.md index 3195c35..5095acd 100644 --- a/openspec/specs/probe-config/spec.md +++ b/openspec/specs/probe-config/spec.md @@ -27,7 +27,7 @@ 系统 SHALL 通过单一命令行参数接受 YAML 配置文件路径。 #### Scenario: 指定配置文件启动 -- **WHEN** 用户执行 `./gateway-checker ./probes.yaml` +- **WHEN** 用户执行 `./dial-server ./probes.yaml` - **THEN** 系统 SHALL 读取并解析指定路径的 YAML 文件作为配置 #### Scenario: 未提供配置文件路径 diff --git a/package.json b/package.json index 827943d..555791a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "gateway-checker", + "name": "dial-server", "type": "module", "private": true, "scripts": { diff --git a/probes.example.yaml b/probes.example.yaml index 2460ab6..e0d83c7 100644 --- a/probes.example.yaml +++ b/probes.example.yaml @@ -99,13 +99,13 @@ targets: http: url: "https://httpbin.org/headers" headers: - X-Custom-Header: "gateway-checker" + X-Custom-Header: "dial-server" expect: status: [200] body: - json: path: "$.headers.X-Custom-Header" - equals: "gateway-checker" + equals: "dial-server" - name: "响应头自定义校验" type: http diff --git a/scripts/build.ts b/scripts/build.ts index afb52e9..74e5e9a 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -5,7 +5,7 @@ import { $ } from "bun"; const buildDir = fileURLToPath(new URL("../.build/", import.meta.url)); const webDistDir = fileURLToPath(new URL("../dist/web/", import.meta.url)); -const executablePath = fileURLToPath(new URL("../dist/gateway-checker", import.meta.url)); +const executablePath = fileURLToPath(new URL("../dist/dial-server", import.meta.url)); const generatedAssetsPath = fileURLToPath(new URL("../.build/static-assets.ts", import.meta.url)); const generatedEntryPath = fileURLToPath(new URL("../.build/server-entry.ts", import.meta.url)); diff --git a/scripts/smoke.ts b/scripts/smoke.ts index 20326cc..108eda3 100644 --- a/scripts/smoke.ts +++ b/scripts/smoke.ts @@ -5,11 +5,11 @@ import { join } from "node:path"; import { tmpdir } from "node:os"; import type { HealthResponse, SummaryResponse } from "../src/shared/api"; -const executablePath = process.argv[2] ?? fileURLToPath(new URL("../dist/gateway-checker", import.meta.url)); +const executablePath = process.argv[2] ?? fileURLToPath(new URL("../dist/dial-server", import.meta.url)); await assertExecutableExists(executablePath); -const tempDir = mkdtempSync(join(tmpdir(), "gc-smoke-")); +const tempDir = mkdtempSync(join(tmpdir(), "dial-smoke-")); const configPath = join(tempDir, "probes.yaml"); const port = await getFreePort(); @@ -61,11 +61,11 @@ try { assert(missingTarget.status === 404, "不存在的目标应返回 404"); const { body: rootHtml, response: rootResponse } = await expectText(`${baseUrl}/`, 200); - assert(rootHtml.includes("Gateway Checker"), "前端根页面缺少标题"); + assert(rootHtml.includes("DiAL"), "前端根页面缺少标题"); assert(rootResponse.headers.get("cache-control") === "no-cache", "前端根页面应使用 no-cache"); const { body: fallbackHtml } = await expectText(`${baseUrl}/dashboard`, 200); - assert(fallbackHtml.includes("Gateway Checker"), "SPA fallback 未返回前端入口页面"); + assert(fallbackHtml.includes("DiAL"), "SPA fallback 未返回前端入口页面"); const assetPath = rootHtml.match(/(?:src|href)="(\/assets\/[^"]+)"/)?.[1]; assert(assetPath !== undefined, "前端入口页面未引用 /assets/* 资源"); @@ -74,7 +74,7 @@ try { assert(asset.status === 200, `静态资源 ${assetPath} 未返回 200`); const missingAsset = await expectText(`${baseUrl}/assets/not-found.js`, 404); - assert(!missingAsset.body.includes("Gateway Checker"), "未知静态资源不应返回前端入口页面"); + assert(!missingAsset.body.includes("DiAL"), "未知静态资源不应返回前端入口页面"); console.log(`Smoke test passed: ${baseUrl}`); } catch (error) { diff --git a/src/server/app.ts b/src/server/app.ts index e36e5a6..bea351e 100644 --- a/src/server/app.ts +++ b/src/server/app.ts @@ -244,7 +244,7 @@ function formatDuration(ms: number): string { function createHealthResponse(): HealthResponse { return { ok: true, - service: "gateway-checker", + service: "dial-server", timestamp: new Date().toISOString(), }; } diff --git a/src/server/config.ts b/src/server/config.ts index 124d8e3..dcd11b6 100644 --- a/src/server/config.ts +++ b/src/server/config.ts @@ -1,6 +1,6 @@ export function readRuntimeConfig(argv: string[] = process.argv.slice(2)): { configPath: string } { if (argv.length === 0) { - throw new Error("需要指定 YAML 配置文件路径\n用法: gateway-checker "); + throw new Error("需要指定 YAML 配置文件路径\n用法: dial-server "); } return { configPath: argv[0]! }; diff --git a/src/server/server.ts b/src/server/server.ts index 7ef1506..e4f5192 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -23,7 +23,7 @@ export function startServer(options: StartServerOptions) { }), }); - console.log(`Gateway Checker listening on ${server.url}`); + console.log(`DiAL listening on ${server.url}`); return server; } diff --git a/src/shared/api.ts b/src/shared/api.ts index 59fa957..09864a2 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -2,7 +2,7 @@ export type RuntimeMode = "development" | "production" | "test"; export interface HealthResponse { ok: true; - service: "gateway-checker"; + service: "dial-server"; timestamp: string; } diff --git a/src/web/app.tsx b/src/web/app.tsx index 099ddd2..e6bcc53 100644 --- a/src/web/app.tsx +++ b/src/web/app.tsx @@ -39,8 +39,8 @@ export function App() { return (
-

Gateway Checker

-

HTTP 拨测监控面板

+

DiAL

+

统一拨测平台

{error &&
请求失败: {error},将在下一次轮询周期自动重试
} diff --git a/src/web/index.html b/src/web/index.html index 8349490..e63e76c 100644 --- a/src/web/index.html +++ b/src/web/index.html @@ -3,8 +3,8 @@ - - Gateway Checker + + DiAL
diff --git a/tests/server/app.test.ts b/tests/server/app.test.ts index 65f777f..37d9242 100644 --- a/tests/server/app.test.ts +++ b/tests/server/app.test.ts @@ -7,7 +7,7 @@ import { join } from "node:path"; import { tmpdir } from "node:os"; const staticAssets: StaticAssets = { - indexHtml: new Blob(['Gateway Checker
'], { + indexHtml: new Blob(['DiAL
'], { type: "text/html", }), files: { @@ -21,7 +21,7 @@ describe("API 路由", () => { let fetchHandler: ReturnType; beforeAll(async () => { - tempDir = join(tmpdir(), `gc-api-test-${Date.now()}`); + tempDir = join(tmpdir(), `dial-api-test-${Date.now()}`); await mkdir(tempDir, { recursive: true }); store = new ProbeStore(join(tempDir, "test.db")); store.syncTargets([ @@ -93,7 +93,7 @@ describe("API 路由", () => { expect(response.status).toBe(200); expect(body.ok).toBe(true); - expect(body.service).toBe("gateway-checker"); + expect(body.service).toBe("dial-server"); }); test("/api/summary 返回总览统计", async () => {