# Haiyi Public Site

This repository is the source of truth for the public website on `www.haiyihy.com` and the H5 pages on `h5.haiyihy.com`.

## Structure

- `www/`: static files served for `https://www.haiyihy.com`
- `h5/`: static files served for `https://h5.haiyihy.com`
- `h5/ranking/`: Yumi-compatible ranking page using `https://jvapi.haiyihy.com`

Every page is stored as complete HTML/CSS/JS files in git. There is no JSON-driven page generation step in production anymore.

## Edit Workflow

```bash
cd public-site
edit www/... or h5/...
git add .
git commit
git push
```

## Production Sync

Production keeps a dedicated clone on the public-site server and syncs it every 20 seconds through `systemd`:

- server repo: `/opt/haiyihy-public-site/repo`
- origin runtime: `/opt/haiyihy-public-site/runtime`
- sync timer: `haiyihy-public-site-sync.timer`
- source origin domains:
  - `www-origin.haiyihy.com`
  - `h5-origin.haiyihy.com`

The origin server serves static files directly from the git checkout:

- `repo/www` -> `www.haiyihy.com` / `www-origin.haiyihy.com`
- `repo/h5` -> `h5.haiyihy.com` / `h5-origin.haiyihy.com`

User-facing traffic goes through Tencent Cloud CDN. CDN pulls from the two `*-origin.haiyihy.com` domains.

## Cache Strategy

- HTML routes: short cache on origin/CDN
- Static assets: long cache on origin/CDN
- Fast bypass:
  - append `?t=...`
  - purge in Tencent Cloud International CDN console
  - run the purge script:

```bash
./deploy/tencent-prod/refresh_public_site_cdn.sh
```

## Bootstrap / Redeploy

```bash
./deploy/tencent-prod/redeploy_public_site.sh
```
