Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b8cf45da1 |
@@ -1439,12 +1439,15 @@ Publishing is a separate step from building, and the separation is the point: th
|
||||
the site server reads is only touched once a build has succeeded, so a failed build
|
||||
leaves the previous site up rather than replacing it with a half-written one.
|
||||
|
||||
**Two gates before the build starts.** The first waits for `/api/health` to answer 200,
|
||||
because `After=` orders a start and does not wait for a port. The second counts
|
||||
`/api/mints` and refuses to build below `MIN_MINTS_FOR_BUILD`, default 20.
|
||||
**Two gates before the build starts.** The first waits for `/api/mints` to answer,
|
||||
because `After=` orders a start and does not wait for a port. It deliberately does not
|
||||
wait for `/api/health` to say `ok`: health is 503 while discovery is starved, which can
|
||||
last until the next backfill, and that is an alert rather than a reason to stop
|
||||
publishing. The second counts `/api/mints` and refuses to build below
|
||||
`MIN_MINTS_FOR_BUILD`, default 20.
|
||||
|
||||
The second exists because health answering 200 and the index being complete are
|
||||
different claims. A year of ~31-event backfills left a perfectly healthy API serving a
|
||||
The second exists because an API that answers, even a healthy one, and an index that is
|
||||
complete are different claims. A year of ~31-event backfills left a perfectly healthy API serving a
|
||||
real, correct, complete list of eight mints; a build against that succeeds, prerenders
|
||||
eight cards, and `rsync --delete-after` replaces fifty-five with eight. The gate runs as
|
||||
an `ExecStartPre`, so a refusal aborts the unit before `pnpm build` — and publishing is
|
||||
@@ -1484,16 +1487,24 @@ Environment=SITE_URL=https://cashumints.space
|
||||
# .env — so what a production build emits cannot drift with an edit to that file.
|
||||
Environment=PUBLIC_API_URL=
|
||||
|
||||
# After= orders the start; it does not wait for the port to accept connections. At boot
|
||||
# the API is still opening its database and probing, so block until it reports healthy
|
||||
# rather than letting the first fetch die on ECONNREFUSED. /api/health answers 503 until
|
||||
# it is genuinely ready, and curl -f treats that as a failure, so the loop keeps waiting.
|
||||
ExecStartPre=/usr/bin/timeout 90 /bin/sh -c 'until curl -sf -o /dev/null http://127.0.0.1:8788/api/health; do sleep 1; done'
|
||||
# After= orders the start; it does not wait for the port to accept connections. Right
|
||||
# after a boot or an API restart the port may not be open yet, so block until the API
|
||||
# answers the list the build reads, rather than letting the first fetch die on
|
||||
# ECONNREFUSED. curl -f treats anything but a 2xx as a failure, so the loop keeps waiting.
|
||||
#
|
||||
# Not /api/health. Health answers 503 whenever its status is not `ok`, and a starved
|
||||
# backfill holds it there until the next backfill reads enough events — days, on a thin
|
||||
# relay set. That is a reason to alert, not a reason to stop publishing: on 2026-10-05
|
||||
# health was 503 against an API serving 91 mints, so a deploy could not get past a gate
|
||||
# that waited for it. Whether there is enough index to build from is the next gate's
|
||||
# question, and it answers it by counting. An empty database answers `[]` here and is
|
||||
# refused there at zero.
|
||||
ExecStartPre=/usr/bin/timeout 90 /bin/sh -c 'until curl -sf -o /dev/null http://127.0.0.1:8788/api/mints; do sleep 1; done'
|
||||
|
||||
# Then: does the API actually have an index to build a site out of?
|
||||
#
|
||||
# Health answering 200 says the process is up and its last backfill read something. It
|
||||
# does not say how many mints are in the table, and those are different questions — the
|
||||
# The API answering says the process is up. It does not say how many mints are in the
|
||||
# table, and even a healthy API cannot say that: those are different questions — the
|
||||
# year of ~31-event backfills had a healthy API serving a real, complete, correct list of
|
||||
# eight mints. A build against that succeeds, prerenders eight cards, and rsync happily
|
||||
# replaces fifty-five with eight.
|
||||
|
||||
+4
-2
@@ -441,8 +441,10 @@ export function resetStatsCache(): void {
|
||||
*
|
||||
* A deployment with an empty database reports degraded until its first backfill lands,
|
||||
* because until then nothing has confirmed the relay set reads anything at all. That is
|
||||
* intended: it holds `cashumints-web.service` at its health gate rather than letting it
|
||||
* publish a site built from nothing.
|
||||
* intended, but it is no longer what keeps a site from being built out of nothing:
|
||||
* `cashumints-web.service` waits for `/api/mints` to answer and refuses a list below
|
||||
* `MIN_MINTS_FOR_BUILD`. It used to wait for this to say `ok`, and a starved backfill
|
||||
* kept it at 503 against a full index, so no deploy could get past it.
|
||||
*/
|
||||
export async function getHealth(): Promise<Health> {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
||||
@@ -58,16 +58,24 @@ Environment=SITE_URL=https://cashumints.space
|
||||
# production build emits cannot drift with an edit to that file.
|
||||
Environment=PUBLIC_API_URL=
|
||||
|
||||
# After= orders the start; it does not wait for the port to accept connections. At boot
|
||||
# the API is still opening its database and probing, so block until it reports healthy
|
||||
# rather than letting the first fetch die on ECONNREFUSED. /api/health answers 503 until
|
||||
# it is genuinely ready, and curl -f treats that as a failure, so the loop keeps waiting.
|
||||
ExecStartPre=/usr/bin/timeout 90 /bin/sh -c 'until curl -sf -o /dev/null http://127.0.0.1:8788/api/health; do sleep 1; done'
|
||||
# After= orders the start; it does not wait for the port to accept connections. Right
|
||||
# after a boot or an API restart the port may not be open yet, so block until the API
|
||||
# answers the list the build reads, rather than letting the first fetch die on
|
||||
# ECONNREFUSED. curl -f treats anything but a 2xx as a failure, so the loop keeps waiting.
|
||||
#
|
||||
# Not /api/health. Health answers 503 whenever its status is not `ok`, and a starved
|
||||
# backfill holds it there until the next backfill reads enough events — days, on a thin
|
||||
# relay set. That is a reason to alert, not a reason to stop publishing: on 2026-10-05
|
||||
# health was 503 against an API serving 91 mints, so a deploy could not get past a gate
|
||||
# that waited for it. Whether there is enough index to build from is the next gate's
|
||||
# question, and it answers it by counting. An empty database answers `[]` here and is
|
||||
# refused there at zero.
|
||||
ExecStartPre=/usr/bin/timeout 90 /bin/sh -c 'until curl -sf -o /dev/null http://127.0.0.1:8788/api/mints; do sleep 1; done'
|
||||
|
||||
# Then: does the API actually have an index to build a site out of?
|
||||
#
|
||||
# Health answering 200 says the process is up and its last backfill read something. It
|
||||
# does not say how many mints are in the table, and those are different questions — the
|
||||
# The API answering says the process is up. It does not say how many mints are in the
|
||||
# table, and even a healthy API cannot say that: those are different questions — the
|
||||
# year of ~31-event backfills had a healthy API serving a real, complete, correct list of
|
||||
# eight mints. A build against that succeeds, prerenders eight cards, and rsync happily
|
||||
# replaces fifty-five with eight.
|
||||
|
||||
Reference in New Issue
Block a user