diff --git a/.env.example b/.env.example index abf917e7..9640bba2 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ NUXT_PUBLIC_API_URL=https://kms.ikxin.com NUXT_PUBLIC_I18N_BASE_URL=https://kms.ikxin.com NUXT_MONITOR_LIST=kms.org.cn,win.freekms.cn -NUXT_ENABLE_VLMCSD=false NUXT_MONITOR_INTERVAL=10 diff --git a/CHANGELOG.md b/CHANGELOG.md index dad7f128..33863986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - 新增暗色模式支持(亮色 / 暗色 / 跟随系统) - 新增国际化支持(简体中文 / English) - 新增 ECharts 图表可视化监控数据 -- 新增内置 VLMCSD 服务(可选启用) - 新增定时任务自动监控 KMS 服务器状态 ### 🛠️ Improvements diff --git a/Dockerfile b/Dockerfile index 2cdbb3d6..a63df239 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ -FROM node:20-slim AS builder +FROM alpine:latest AS vlmcsd-builder + +WORKDIR /root + +RUN apk add --no-cache git make build-base && \ + git clone --branch master --single-branch https://github.com/Wind4/vlmcsd.git && \ + cd vlmcsd/ && \ + make + +FROM node:20-slim AS app-builder WORKDIR /app @@ -12,10 +21,10 @@ RUN NITRO_PRESET=node-server pnpm run build FROM node:20-slim -COPY --from=builder /app/.output /app/.output -COPY --from=builder /app/binaries /app/binaries +COPY --from=vlmcsd-builder /root/vlmcsd/bin/vlmcsd /usr/bin/vlmcsd +COPY --from=app-builder /app/.output /app/.output -RUN chmod -R +x /app/binaries +RUN chmod +x /usr/bin/vlmcsd WORKDIR /app @@ -26,4 +35,4 @@ EXPOSE 3000 1688 ENV HOST=0.0.0.0 ENV PORT=3000 -CMD ["node", ".output/server/index.mjs"] +CMD ["sh", "-c", "/usr/bin/vlmcsd -D -e & node .output/server/index.mjs"] diff --git a/README.en.md b/README.en.md index 33cea2d7..15ecffa7 100644 --- a/README.en.md +++ b/README.en.md @@ -72,13 +72,12 @@ The static version uses https://kms.ikxin.com API by default. You can deploy you ### Environment Variables -| Name | Example | Description | -| -------------------------- | --------------------------- | ---------------------------------------------------------------------- | -| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | API URL for the static version | -| `NUXT_MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | Custom KMS server monitoring list, separated by `,` | -| `NUXT_MONITOR_INTERVAL` | `10` | Monitoring interval in seconds, default is 10 | -| `NUXT_ENABLE_VLMCSD` | `false` | Whether to enable the built-in VLMCSD service | -| `PORT` | `3000` | Server listening port (also accepts `NITRO_PORT`) | +| Name | Example | Description | +| ----------------------- | --------------------------- | --------------------------------------------------- | +| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | API URL for the static version | +| `NUXT_MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | Custom KMS server monitoring list, separated by `,` | +| `NUXT_MONITOR_INTERVAL` | `10` | Monitoring interval in seconds, default is 10 | +| `PORT` | `3000` | Server listening port (also accepts `NITRO_PORT`) | > [!NOTE] > The production server (`node .output/server/index.mjs`) does **not** automatically load `.env` files. Environment variables must be set in the system environment or your deployment platform before starting the server. The `.env` file is only used during development and the build phase. diff --git a/README.md b/README.md index 4f28280a..fd55b747 100644 --- a/README.md +++ b/README.md @@ -72,13 +72,12 @@ https://kms.ikxin.com ### 环境变量 -| 名称 | 示例值 | 描述 | -| -------------------------- | --------------------------- | ----------------------------------------------------------------- | -| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | 静态版本 API 接口地址 | -| `NUXT_MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | 自定义监控 KMS 服务器列表,使用 `,` 分隔 | -| `NUXT_MONITOR_INTERVAL` | `10` | 监控频率,单位为秒,默认 10 秒 | -| `NUXT_ENABLE_VLMCSD` | `false` | 是否启用内置 VLMCSD 服务 | -| `PORT` | `3000` | 服务监听端口(也可使用 `NITRO_PORT`) | +| 名称 | 示例值 | 描述 | +| ----------------------- | --------------------------- | ---------------------------------------- | +| `NUXT_PUBLIC_API_URL` | `https://kms.ikxin.com` | 静态版本 API 接口地址 | +| `NUXT_MONITOR_LIST` | `kms.org.cn,win.freekms.cn` | 自定义监控 KMS 服务器列表,使用 `,` 分隔 | +| `NUXT_MONITOR_INTERVAL` | `10` | 监控频率,单位为秒,默认 10 秒 | +| `PORT` | `3000` | 服务监听端口(也可使用 `NITRO_PORT`) | > [!NOTE] > 生产环境(`node .output/server/index.mjs`)不会自动读取 `.env` 文件,环境变量需要在运行前通过系统环境或部署平台进行配置。`.env` 文件仅在开发和构建阶段有效。 diff --git a/binaries/vlmcsd-darwin-arm64 b/binaries/vlmcsd-darwin-arm64 deleted file mode 100755 index 699c38b6..00000000 Binary files a/binaries/vlmcsd-darwin-arm64 and /dev/null differ diff --git a/binaries/vlmcsd-darwin-x64 b/binaries/vlmcsd-darwin-x64 deleted file mode 100755 index 64674305..00000000 Binary files a/binaries/vlmcsd-darwin-x64 and /dev/null differ diff --git a/binaries/vlmcsd-linux-arm64 b/binaries/vlmcsd-linux-arm64 deleted file mode 100755 index 9aefe58c..00000000 Binary files a/binaries/vlmcsd-linux-arm64 and /dev/null differ diff --git a/binaries/vlmcsd-linux-x64 b/binaries/vlmcsd-linux-x64 deleted file mode 100755 index 037cbefa..00000000 Binary files a/binaries/vlmcsd-linux-x64 and /dev/null differ diff --git a/nuxt.config.ts b/nuxt.config.ts index 747a1800..23ed027c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -40,7 +40,6 @@ export default defineNuxtConfig({ }, runtimeConfig: { monitorList: '', - enableVlmcsd: '', monitorInterval: '10', public: { apiUrl: '', diff --git a/server/plugins/vlmcsd.ts b/server/plugins/vlmcsd.ts deleted file mode 100644 index 3d1ef11f..00000000 --- a/server/plugins/vlmcsd.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { spawn } from 'child_process' -import { join } from 'path' -import { arch, platform } from 'os' -import { existsSync } from 'fs' - -export default defineNitroPlugin(nitro => { - const config = useRuntimeConfig() - const enableVlmcsd = - config.enableVlmcsd === true || - config.enableVlmcsd === 'true' || - process.env.ENABLE_VLMCSD === 'true' - - if (!enableVlmcsd) { - console.log('Vlmcsd is disabled') - return - } - - const vlmcsdPath = join( - process.cwd(), - 'binaries', - `vlmcsd-${platform()}-${arch()}` - ) - - if (!existsSync(vlmcsdPath)) { - console.log('Vlmcsd binary not found') - return - } - - const vlmcsd = spawn(vlmcsdPath, ['-D'], { stdio: 'inherit' }) - - nitro.hooks.hookOnce('close', () => { - vlmcsd.removeAllListeners() - vlmcsd.kill() - }) -})