Mercurial
comparison hg-web/README.md @ 249:c5129452493e
[deploy] Bundle Mercurial with hg-web
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 04 Aug 2026 04:16:45 -0700 |
| parents | 8bb0ac8f4587 |
| children |
comparison
equal
deleted
inserted
replaced
| 248:b8b6e726964a | 249:c5129452493e |
|---|---|
| 191 ```bash | 191 ```bash |
| 192 bazel run //hg-web:dev | 192 bazel run //hg-web:dev |
| 193 ``` | 193 ``` |
| 194 | 194 |
| 195 This starts `hg serve` on `127.0.0.1:4444` and `hg_web_server` on port `6970`. | 195 This starts `hg serve` on `127.0.0.1:4444` and `hg_web_server` on port `6970`. |
| 196 Stopping the Bazel target stops both child processes. | 196 The `hg serve` process comes from `//third_party/mercurial:runtime` and points at |
| 197 | 197 the current workspace. Stopping the Bazel target stops both child processes. |
| 198 The bundle contains `hg_web_server` and `hg-web/src/`, including generated | 198 |
| 199 `page.js`, markdown WASM, highlight.js, styles, and image assets. | 199 The bundle contains `hg_web_server`, `hg-web/run_hg_web`, a pinned pure-Python |
| 200 Mercurial runtime, and `hg-web/src/`, including generated `page.js`, markdown | |
| 201 WASM, highlight.js, styles, and image assets. | |
| 200 | 202 |
| 201 ## Deployment contract | 203 ## Deployment contract |
| 202 | 204 |
| 203 The expected production layout is: | 205 The expected production layout is: |
| 204 | 206 |
| 205 ```text | 207 ```text |
| 206 nginx | 208 nginx |
| 207 -> hg_web_server.service | 209 -> hg_web_server.service |
| 208 -> /opt/hg_web_server_bundle_active/hg_web_server | 210 -> /opt/hg_web_server/active/hg-web/run_hg_web |
| 209 -> working directory: /opt/hg_web_server_bundle_active | 211 -> bundled Mercurial 7.2.3 serves |
| 210 -> hg serve service on 127.0.0.1:4444 | 212 /opt/hg_web_server/repository on 127.0.0.1:4444 |
| 211 ``` | 213 -> hg_web_server serves the forge on 127.0.0.1:6970 |
| 212 | 214 ``` |
| 213 `deploy.sh` builds an optimized bundle into a revisioned release directory, | 215 |
| 214 atomically repoints `/opt/hg_web_server_bundle_active`, restarts | 216 `deploy.sh` follows the same new/active bundle swap as the personal site. It |
| 215 `hg_web_server.service`, and checks `http://127.0.0.1:6970/`. A failed restart | 217 builds the optimized bundle and maintains a canonical repository outside the |
| 216 or health check restores the previous release and restarts it. The service, | 218 release directories. The first deploy creates it with a locking-aware local |
| 217 release root, active path, health URL, user, and group can be overridden with | 219 clone. Later deploys create a Mercurial bundle from the workspace and pull that |
| 218 environment variables. | 220 bundle into the persistent repository, preserving any commits pushed directly |
| 221 to production. The script verifies the repository, installs the systemd unit, | |
| 222 swaps the active directory, restarts the combined service, and checks | |
| 223 `http://127.0.0.1:6970/`. A failed restart restores the previous active | |
| 224 directory. | |
| 225 | |
| 226 There is no separate production `hg serve` service and no dependency on the | |
| 227 host's `hg` command. The pinned Mercurial wheel requires CPython 3.11. The | |
| 228 systemd unit uses `KillMode=control-group`, so both the Mercurial and C child | |
| 229 processes stop together. | |
| 230 | |
| 231 On its first run, deploy also installs `/etc/nginx/sites-available/hg-web` when | |
| 232 Nginx uses Debian-style `sites-available`/`sites-enabled` directories. Existing | |
| 233 site files are left untouched. | |
| 234 | |
| 235 ```bash | |
| 236 NGINX_SERVER_NAME=zenbu.babocoder.com bazel run //hg-web:deploy | |
| 237 ``` | |
| 238 | |
| 239 The checked-in template listens on origin HTTP port 80, which works when TLS is | |
| 240 terminated upstream. For direct origin TLS, provide a complete certificate-aware | |
| 241 template: | |
| 242 | |
| 243 ```bash | |
| 244 NGINX_SITE_TEMPLATE=/etc/nginx/templates/hg-web-tls.conf \ | |
| 245 bazel run //hg-web:deploy | |
| 246 ``` | |
| 247 | |
| 248 Set `MANAGE_NGINX=false` to leave Nginx untouched. `NGINX_SITE_NAME`, | |
| 249 `NGINX_SITE_AVAILABLE`, and `NGINX_SITE_ENABLED` can override the destination | |
| 250 names and paths. `DEPLOY_ROOT` controls the validated deployment root; | |
| 251 `REPOSITORY_PATH` can override the persistent canonical repository within it. | |
| 252 | |
| 253 Pushes are disabled by default. `HG_ALLOW_PUSH=true` enables unauthenticated | |
| 254 pushes in the internal `hg serve`; only use it when `/repo` is protected by | |
| 255 Nginx authentication or another trusted access layer. | |
| 219 | 256 |
| 220 ## Publishing | 257 ## Publishing |
| 221 | 258 |
| 222 Push committed Mercurial changes to the configured server: | 259 Push committed Mercurial changes to the configured server: |
| 223 | 260 |