Skip to content

Commit 24fe688

Browse files
claudeconnortsui20
authored andcommitted
benchmarks-website/ops: force-rebuild path for "redeploy current branch"
The deploy timer's fast-path exit when `origin/$DEPLOY_BRANCH` hasn't moved is the right default — but it means there's no way to say "I want a fresh build of whatever's on the branch I'm tracking right now, even though origin hasn't moved." Real situations that hit this: - Flipped DEPLOY_BRANCH and want the new tip within seconds, not on the next commit there. - Edited /etc/vortex-bench.env in a way that needs a rebuild (build flags, target paths) rather than just a `systemctl restart`. - target/ got wedged and you want a clean rebuild from scratch. deploy.sh now accepts either `FORCE=1` in the environment or a `.force-rebuild` sentinel file under `$STATE_DIR`. Either path skips the stamp comparison so the full build → atomic swap → restart → /health cycle runs against `origin/$DEPLOY_BRANCH`. The sentinel is consumed on consumption so the very next ordinary timer tick is a normal no-op again. ops/force-rebuild.sh is a one-liner wrapper that drops the sentinel and triggers the deploy service — operator-facing, no env vars or systemd-override invocations to remember. ops/README.md grows a "How do I manually restart or redeploy?" section with three knobs in increasing order of work: restart-only, deploy-if-moved, and force-rebuild. Drops the earlier "manual cargo build from a local checkout" path which was over-documented; the force-rebuild + DEPLOY_BRANCH flip covers the same ground without encouraging hand-edited build state on the host. Signed-off-by: Claude <noreply@anthropic.com>
1 parent bcea915 commit 24fe688

3 files changed

Lines changed: 108 additions & 1 deletion

File tree

benchmarks-website/ops/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ out-of-tree state — every script and unit lives in
9191
| [`migrate.sh`](migrate.sh) | Manual: stop, snapshot prev DB, run migrate, restart. |
9292
| [`backup.sh`](backup.sh) | Hourly: trigger `/api/admin/snapshot`, sync to S3, prune local. |
9393
| [`inspect.sh`](inspect.sh) | Read-only SQL via `/api/admin/sql`, no server stop. |
94+
| [`force-rebuild.sh`](force-rebuild.sh) | Re-run a deploy of `$DEPLOY_BRANCH` even when origin hasn't moved. |
9495
| [`config/vortex-bench.env.example`](config/vortex-bench.env.example) | Template for `/etc/vortex-bench.env`. |
9596
| [`systemd/`](systemd/) | Unit files installed into `/etc/systemd/system/`. |
9697

@@ -346,6 +347,51 @@ The timer's next fire (within 60s) will overwrite your manual binary
346347
with whatever `origin/$DEPLOY_BRANCH` produces, which is usually what
347348
you want — manual binaries are scratch space, not a long-term state.
348349

350+
### "How do I manually restart or redeploy?"
351+
352+
Three knobs, in increasing order of work done:
353+
354+
**(a) Restart the running binary, no rebuild.** Cheapest restart;
355+
useful after editing `/etc/vortex-bench.env` or recovering from a hung
356+
connection. `build_sha` on `/health` will be unchanged afterwards.
357+
358+
```bash
359+
sudo systemctl restart vortex-bench-server
360+
journalctl -fu vortex-bench-server # confirm it came up
361+
```
362+
363+
**(b) Run a deploy now if origin has moved.** Triggers the same flow
364+
the 60s timer runs. No-op if `origin/$DEPLOY_BRANCH` hasn't moved
365+
since the last successful deploy.
366+
367+
```bash
368+
sudo systemctl start vortex-bench-deploy.service
369+
journalctl -fu vortex-bench-deploy.service
370+
```
371+
372+
**(c) Force-rebuild `origin/$DEPLOY_BRANCH` even if origin hasn't
373+
moved.** Ignores the stamp-file comparison and the path filter and
374+
runs the full build → atomic swap → restart → `/health` check. Use
375+
this when you want to redeploy "whatever's on the branch I'm tracking"
376+
without waiting for a new commit — e.g. after flipping `DEPLOY_BRANCH`
377+
or recovering from wedged build artefacts:
378+
379+
```bash
380+
/var/lib/vortex-bench/ops/force-rebuild.sh
381+
journalctl -fu vortex-bench-deploy.service
382+
```
383+
384+
Under the hood, `force-rebuild.sh` drops a `.force-rebuild` sentinel
385+
under `$STATE_DIR` and triggers `vortex-bench-deploy.service`. The
386+
script consumes the sentinel on its next fire, so the very next
387+
ordinary timer tick is a normal no-op again.
388+
389+
To test a branch that isn't `$DEPLOY_BRANCH`, edit the env file to
390+
point `DEPLOY_BRANCH` at it, then call `force-rebuild.sh` (or wait
391+
60s). The deploy script always builds origin's tip — there is no
392+
"build whatever I have locally checked out" mode by design. Push to
393+
a branch first.
394+
349395
### "A vortex-array PR landed — does the website rebuild?"
350396

351397
No. The path filter ignores anything outside the directories listed

benchmarks-website/ops/deploy.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,26 @@ if ! git fetch --quiet origin "$DEPLOY_BRANCH"; then
9090
fi
9191
new_sha="$(git rev-parse "origin/${DEPLOY_BRANCH}")"
9292

93-
if [ "$new_sha" = "$last_sha" ]; then
93+
# --- Force mode ---
94+
# A `FORCE=1` env var (or a `.force-rebuild` sentinel under the state
95+
# dir) bypasses the SHA-unchanged fast path and treats this run as if
96+
# nothing was ever deployed. Used by `force-rebuild.sh` for the
97+
# "redeploy current branch right now" path. The sentinel is consumed
98+
# so the next ordinary timer fire is a no-op again.
99+
force=0
100+
if [ "${FORCE:-0}" = "1" ]; then
101+
force=1
102+
fi
103+
if [ -f "${STATE_DIR}/.force-rebuild" ]; then
104+
rm -f "${STATE_DIR}/.force-rebuild"
105+
force=1
106+
fi
107+
if [ "$force" = "1" ]; then
108+
log "force mode: ignoring stamp comparison and path filter"
109+
last_sha=""
110+
fi
111+
112+
if [ "$force" = "0" ] && [ "$new_sha" = "$last_sha" ]; then
94113
# Common case: nothing new since last fire. Silent on stdout to
95114
# keep the journal clean.
96115
exit 0
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
4+
#
5+
# Force a rebuild + restart of origin/$DEPLOY_BRANCH right now, even
6+
# if origin hasn't moved since the last successful deploy. Drops a
7+
# sentinel that the next deploy.sh fire consumes, then triggers it.
8+
#
9+
# Use cases:
10+
# - You changed /etc/vortex-bench.env and want a fresh binary build
11+
# (e.g. a feature flag baked into config) rather than just a
12+
# `systemctl restart` of the existing one.
13+
# - You flipped DEPLOY_BRANCH and want the new tip in <60s rather
14+
# than waiting for the timer.
15+
# - Build artefacts got wedged and you want a clean rebuild.
16+
#
17+
# For "build whatever I have locally checked out" rather than fetching
18+
# origin, edit /etc/vortex-bench.env to point DEPLOY_BRANCH at a
19+
# branch the local tip is already on, then run this. The deploy
20+
# script always builds origin's tip — there is no "use local HEAD"
21+
# mode by design; push to a branch first.
22+
23+
set -euo pipefail
24+
25+
STATE_DIR="${STATE_DIR:-/var/lib/vortex-bench}"
26+
27+
if [ ! -d "$STATE_DIR" ]; then
28+
echo "ERROR: ${STATE_DIR} not found — has install.sh run?" >&2
29+
exit 2
30+
fi
31+
32+
# The sentinel file needs to be writable by the user the deploy
33+
# service runs as. install.sh chowns STATE_DIR to that user, so this
34+
# works without sudo. If you're running as a different user, sudo.
35+
if ! touch "${STATE_DIR}/.force-rebuild" 2>/dev/null; then
36+
echo "ERROR: cannot write ${STATE_DIR}/.force-rebuild — run as the install user or sudo" >&2
37+
exit 2
38+
fi
39+
40+
echo "[force-rebuild] sentinel dropped; firing deploy service"
41+
sudo /bin/systemctl start vortex-bench-deploy.service
42+
echo "[force-rebuild] tail with: journalctl -fu vortex-bench-deploy.service"

0 commit comments

Comments
 (0)