Files
YMhut-box-C-/server/unified-management/README.md
T

140 lines
3.9 KiB
Markdown

# YMhut Unified Management
This service unifies the old `server/update` and `server/feedback-mailer` projects.
## What It Provides
- Go backend with SQLite by default.
- Optional MySQL configuration with runtime status and failover hooks.
- Legacy routes for `update-info.json`, `tool-status.json`, `media-types.json`, `modules.json`, downloads, and feedback.
- New client discovery through `/api/client/bootstrap`.
- Admin login with default account `admin/admin`.
- Login captcha, HttpOnly session cookie, and CSRF checks.
- In-process media/data source service with scheduled health checks.
- Vue admin/portal source and Rust WASM helper source.
## Run
```powershell
cd server\unified-management
$env:GOPROXY="https://goproxy.io,https://mirrors.aliyun.com/goproxy,direct"
go mod download all
go mod verify
go run main.go
```
These commands only set the proxy for the current PowerShell process and do not modify the global Go configuration. Use `go mod tidy -diff` when reviewing dependency changes; normal startup must not rewrite `go.mod` or `go.sum`.
The startup preflight prints:
- the accepted entrypoint: `go run main.go`
- the listen address
- storage, SQLite, legacy JSON, downloads, and frontend dist status
Alternative command entrypoint:
```powershell
go run .\cmd\unified-management
```
Tests:
```powershell
.\scripts\test.ps1
```
The test and release scripts prefetch the complete module graph through a process-local proxy fallback and verify every module against `go.sum`/`GOSUMDB`. Override the proxy chain without changing global Go settings when needed:
```powershell
$env:YMHUT_GOPROXY="https://your-proxy.example,direct"
.\scripts\test.ps1 -Race
```
`-Race` requires a working C compiler in `PATH`; normal tests and release builds do not.
## Frontend Build Check
Startup preflight checks both built web apps:
- `web/admin/dist/index.html`
- `web/admin/dist/assets`
- `web/portal/dist/index.html`
- `web/portal/dist/assets`
If either frontend is missing, the service still starts, but the preflight log tells you to run the frontend build. Release binaries built with `embed_web` report that embedded frontend assets are being used instead. Build the local dist files with:
```powershell
cd server\unified-management\web\admin
npm install
npm run build
cd ..\portal
npm install
npm run build
```
The Go server serves portal assets from `/assets/*` and admin assets from `/admin/assets/*`. Disk `dist` files are preferred during development; embedded assets are used as the release fallback.
## Release Binaries
Build frontend assets and produce merged backend binaries for Windows and Linux. The scripts run `npm run build` for both web apps and compile Go with `-tags embed_web`, so the resulting binaries include the admin and portal frontends:
```powershell
cd server\unified-management
.\scripts\build-release.ps1 -Version 0.1.0
```
Linux/macOS shell:
```bash
cd server/unified-management
VERSION=0.1.0 ./scripts/build-release.sh
```
Outputs are written to `dist-release/`:
- `ymhut-unified-management-windows-amd64.exe`
- `ymhut-unified-management-linux-amd64`
- `ymhut-unified-management-linux-arm64`
## Default Port
The default listen address is `:33550`.
Override it with either:
```powershell
$env:YMHUT_LISTEN=":33551"
```
or:
```powershell
$env:PORT="33551"
```
## Environment
- `YMHUT_LISTEN`: listen address, default `:33550`
- `YMHUT_BASE_URL`: public endpoint, default `https://update.ymhut.cn`
- `YMHUT_DB_PROVIDER`: `sqlite` or `mysql`
- `YMHUT_SQLITE_PATH`: SQLite path
- `YMHUT_MYSQL_DSN`: MySQL DSN
- `YMHUT_UPDATE_PUBLIC_DIR`: legacy update public directory
- `YMHUT_DOWNLOADS_DIR`: package download directory
- `YMHUT_SOURCE_CHECK_SECONDS`: source health check interval
## Frontend
- `web/admin`: Vue admin console source
- `web/portal`: Vue public portal source
- `web/wasm`: Rust WASM helpers
Rust WASM functions:
- `compareVersions`
- `normalizeReleaseManifest`
- `validateSourceCatalog`
- `scoreEndpointHealth`
- `mergeLegacyMediaTypes`