fix(web): harden route transitions and monitor memory
This commit is contained in:
@@ -26,6 +26,31 @@ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o ../
|
||||
/opt/lingniu-vehicle-platform/env/platform.env
|
||||
```
|
||||
|
||||
## Browser-safe release switch
|
||||
|
||||
The web application splits every major route into a hashed lazy-loaded asset. An already-open browser tab can therefore request the previous release's route asset after `current` has switched. Keep exactly one previous generation of original build assets in the new release before the atomic symlink switch:
|
||||
|
||||
```bash
|
||||
CURRENT_WEB=/opt/lingniu-vehicle-platform/current/web
|
||||
NEW_WEB=/opt/lingniu-vehicle-platform/releases/$PLATFORM_RELEASE/web
|
||||
|
||||
# Record only this release's own build assets before adding compatibility files.
|
||||
find "$NEW_WEB/assets" -type f -printf '%P\n' | sort > "$NEW_WEB/.release-assets"
|
||||
|
||||
if [ -f "$CURRENT_WEB/.release-assets" ]; then
|
||||
while IFS= read -r asset; do
|
||||
test -n "$asset" || continue
|
||||
mkdir -p "$NEW_WEB/assets/$(dirname "$asset")"
|
||||
cp -n "$CURRENT_WEB/assets/$asset" "$NEW_WEB/assets/$asset"
|
||||
done < "$CURRENT_WEB/.release-assets"
|
||||
else
|
||||
# One-time compatibility for releases created before the manifest existed.
|
||||
cp -an "$CURRENT_WEB/assets/." "$NEW_WEB/assets/"
|
||||
fi
|
||||
```
|
||||
|
||||
Never overwrite a new hashed file. The `.release-assets` manifest prevents compatibility files from accumulating recursively: the next release copies only the immediately previous build's original assets. The React route boundary also detects a failed dynamic import, reloads once with a short cooldown and keeps the application shell usable if recovery still fails. Verify one old route asset and the new main asset both return HTTP 200 after the switch.
|
||||
|
||||
## Environment
|
||||
|
||||
```text
|
||||
@@ -71,7 +96,7 @@ ALERT_STREAM_LATENESS_SEC=120
|
||||
|
||||
`AMAP_WEB_JS_KEY` is served to the browser through `/app-config.js` so the same static build can be reused across environments. For production, set both `AMAP_SECURITY_JS_CODE` and `AMAP_SECURITY_SERVICE_HOST=/_AMapService`; the API service keeps the security code on the server and proxies AMap requests with `jscode` appended. Only omit `AMAP_SECURITY_SERVICE_HOST` for controlled debugging where exposing `AMAP_SECURITY_JS_CODE` to the browser is acceptable. `AMAP_API_KEY` is reserved for backend-only AMap service APIs such as geocoding, route planning, geofence, or trajectory service integration.
|
||||
|
||||
`PLATFORM_RELEASE` is surfaced by `/api/ops/health.runtime.platformRelease` so operators can confirm which ECS release is currently active after a deployment.
|
||||
`PLATFORM_RELEASE` is surfaced by `/api/ops/health` at `data.runtime.platformRelease` so operators can confirm which ECS release is currently active after a deployment.
|
||||
|
||||
All three platform systemd units first load `/opt/lingniu-go-native/env/base.env` for the existing MySQL, Redis, TDengine and Kafka connection settings, then load `platform.env` for platform-specific overrides. `DATA_MODE=production` is mandatory on ECS: a missing or unreachable MySQL connection returns `DATA_STORE_UNAVAILABLE` instead of silently serving demonstration data. Use `DATA_MODE=mock` only for local development.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user