Operations & Deployment Runbook
Operational tasks consolidated from the legacy deployment checklists.
Before You Deploy
- Secrets – confirm Wrangler secrets exist for:
BASE44_API_URL,BASE44_JWT_SECRET(or app key).DATAFORSEO_LOGIN,DATAFORSEO_PASSWORD.CLICKHOUSE_HOST,CLICKHOUSE_USER,CLICKHOUSE_PASSWORD,CLICKHOUSE_DATABASE.CF_IMAGES_ACCOUNT_ID,CF_IMAGES_API_TOKEN,CF_IMAGES_ACCOUNT_HASH(for icon storage).ZENROWS_API_KEY(for proxied iTunes API calls when blocked).
- Reference data – run once per environment:
npm run seed:business-typesnpm run push:dataforseo-categories
- Queues & storage – ensure KV namespaces (
DFS_*,DATAFORSEO_CATEGORIES), queues (dfs_run,harvest_keywords), and R2 bucket (dfs-raw-payloads) exist in Cloudflare. - React alignment – confirm frontend is prepared for new metadata fields (
sources,brand_flag, intents).
Deploying
wrangler deploy
- Deploys worker + queue consumer from
wrangler.toml. - Watch logs with
wrangler tailwhile running a sample/runto catch runtime errors early.
Post-Deploy Verification
- Schema health
Expect all
curl https://<worker>/test/clickhouse*_existsflags true. - Smoke test workflow
curl -X POST https://<worker>/run -d '{"url":"https://slack.com","project_id":"test"}'- Poll
/run/{id}/statusuntilawaiting_category_confirmation. - POST
/run/{id}/confirm-categories. - Verify status reaches
completeand ClickHouse receives inserts.
- Poll
- Diagnostics
/admin/business-typesresponds with Base44 data./diagnostics/run/{id}shows enrichment + harvest payloads.
- Queues
- Confirm
harvest_keywordsqueue is draining (no stuck messages). - Check dead-letter queue if inserts fail.
- Confirm
Monitoring & Troubleshooting
- DataForSEO quotas – tune
DATAFORSEO_LABS_LIMITandDATAFORSEO_LABS_MAX_REQUESTSin Wrangler vars if rate limits hit. - ClickHouse failures – inspect queue logs; use
/test/clickhouseto verify connectivity; replay messages after resolving credentials. - Run errors –
harvest.errorsinGET /run/{id}/statussurfaces per-run issues;/diagnostics/run/{id}includes stack traces. - Budget enforcement – KV key
DFS_BUDGETStracks quotas; reset via KV CLI if you need to unblock staging tests. - Apple rate limiting – if seeing 403/429 from iTunes API or HTML scrape, the worker will automatically back off. Check logs for "rate limited" messages.
- CF Images failures – if icons aren't uploading, verify
CF_IMAGES_*secrets are set. Original URLs are used as fallback. - iTunes redirect loops – if seeing
itms-appss://in logs, ensure Desktop Safari UAs are being used (not mobile).
Regular Maintenance
- Nightly sync or cron to refresh ClickHouse reference tables from Base44 (if not already automated).
- Periodic review of
dfs-raw-payloadsR2 bucket; consider retention policy. - Rotate secrets quarterly; update Wrangler secrets and redeploy.
Helpful Scripts
npm run seed:business-types– ensures Base44 has canonical business types.npm run push:dataforseo-categories– loads taxonomy into KV.npm run format/npm test(if added) – sanity checks prior to deploy.
Related References
- Architecture overview:
docs/architecture.md - Backend lifecycle:
docs/backend.md - Schema & endpoints:
docs/reference/schema.md,docs/reference/endpoints.md