Pular para o conteúdo

Scripts & Automation

Dev Environment

scripts/dev.js

Starts the unified dev environment (static site + 4 Workers + proxy):

Terminal window
# Start all services
node scripts/dev.js
# With a fresh site build
node scripts/dev.js --build

scripts/dev-stop.js

Stops all services started by dev.js.

Terminal window
node scripts/dev-stop.js

Daily Build

scripts/daily-build.sh

Publish-only by default (no page regeneration):

  1. generate-sitemap (full disk traversal; writes changed shards only)
  2. validate-schema.py
  3. reconcile-assets (scoped; refuses >500 uploads and honours the freeze)
  4. sitemap-first smart deploy (500-file gate)
  5. gated content deploy (journaled and resumable)
  6. provenance + success marker
Terminal window
./scripts/daily-build.sh # publish-only
FULL_BUILD=1 FORCE_BUILD=1 ./scripts/daily-build.sh # regenerate pages
FULL_BUILD=1 DAILY_REFRESH=1 FORCE_BUILD=1 ./scripts/daily-build.sh

FORCE_BUILD=1 only bypasses the same-day marker; it no longer implies a full build. A malformed site/cache/deploy/FREEZE.json is treated as frozen.

scripts/estate-freeze.sh

Freeze or lift automated estate activity and snapshot the deploy baseline:

Terminal window
./scripts/estate-freeze.sh on --reason "P0 revenue incident" --issue https://github.com/mauricionr/brasil/issues/199
./scripts/estate-freeze.sh status --check
./scripts/estate-freeze.sh off --approval https://github.com/mauricionr/brasil/issues/199#issuecomment-...

off re-enables only the daily build and freshness timers; the four content agents stay disabled.

Systemd Schedule

Units live in scripts/systemd-units/. Install them with:

Terminal window
cp scripts/systemd-units/redecasas-daily-build.{service,timer} ~/.config/systemd/user/
cp scripts/systemd-units/redecasas-build-freshness.{service,timer} ~/.config/systemd/user/
cp scripts/systemd-units/redecasas-gsc-watch.{service,timer} ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now redecasas-daily-build.timer redecasas-build-freshness.timer redecasas-gsc-watch.timer

The daily build runs at 03:00 with a 24h timeout. A 12:00 freshness check alerts when the build or sitemap is stale. See the Daily Build page for the resume and FORCE_REBUILD semantics.

The 13:00 recovery watch runs the daily GSC/AdSense read against operator-dropped exports; unlike the build timers it keeps running through an estate freeze. See the Recovery Watch page for the drop-folder contract and the paging policy.

Recovery

scripts/refetch-missing-cities.sh

Recovery batch 1: one keyed per-city regen per city in the purged-census list (RECOVERY-PURGED-CITIES-2026-11-04.md). Deploy is not part of the script.

scripts/rebase-state-group.sh

Recovery batches 2–5: cache-only per-state regens for the remaining 20 states (G1–G4), with silent no-op detection and the checkpointed deploy procedure. See the State Re-base Groups page.

scripts/verify-overnight-receipts.sh

Morning gate after the automated batch-1 run: machine-verifies every receipt (overnight log, results TSV, determinism gate, last-diff bands, census, audit-metadata, freeze, tree, #198 record) and prints the G1 go/no-go. See the Overnight Receipts Verifier page.

Database

scripts/init-chat-db.sh

Applies D1 migrations for local chat worker development.

scripts/provision-chat.sh

Provisions the chat worker database.

Build & Deploy

scripts/build-chat-indices.js

Builds search indices for the chat worker.

scripts/deploy-all.sh

Deploys all workers with type-checking, D1 migrations, schema verification, and secret upload.

scripts/deploy-auth.sh

Deploys the auth worker specifically.

scripts/deploy-billing.sh

Deploys the billing worker specifically.

scripts/deploy-listings.sh

Deploys the listings worker specifically.

Note: There is no deploy-chat.sh script. Deploy the chat worker individually with cd chat-worker && npm run deploy, or use deploy-all.sh for a full deployment.