Skip to content
MSO CloudDocumentation

Remote collectors (ADR 0065)

On this page

Operator steps to turn on collector ingest, register a collector machine and deliver one weekly batch. Secrets and private keys never appear in chat, logs or the repo. Both processes ship off: with COLLECTOR_INGEST_ENABLED unset the gateway answers 404, and with COLLECTOR_PROMOTE_ENABLED unset sealed batches stay sealed.

1. Enable the database roles (once)#

Migration 0278 creates yng_collector_gw and yng_collector as NOLOGIN NOBYPASSRLS. Add two passwords to .env.prod (openssl rand -hex 32 each): YNG_COLLECTOR_GW_DB_PASSWORD and YNG_COLLECTOR_DB_PASSWORD. The deploy's collector step enables the logins the way --with-idp enables yng_idp: ALTER ROLE ... LOGIN PASSWORD with the value read through \getenv, never echoed.

2. Deploy with the collector services#

Run the deploy through the Monitor tool with a log file and an EXIT_DEPLOY=$? line, with the collector flag, then read the warm-asset-cache: and verify-cdn-cache: lines (§176). The gateway serves ingest.msocloud.net (Cloudflare-proxied). Every response is Cache-Control: no-store.

3. Register a collector machine#

On the collector machine (Node only; the CLI is one bundled file):

mso-collect keygen            # writes ~/.mso-collect/key.pem (mode 600), prints key_id and public_key

On the production host, as the migrator identity:

pnpm tsx scripts/collector/register.ts collector --name seat-a
pnpm tsx scripts/collector/register.ts key --collector seat-a --public-key <public_key> --days 180
pnpm tsx scripts/collector/register.ts feed --key tts-skincare-weekly --source kalodata \
  --platform tiktok-shop --category "Chăm sóc da" --category-id 848776 --grain week --kinds product
pnpm tsx scripts/collector/register.ts grant --collector seat-a --feed tts-skincare-weekly
pnpm tsx scripts/collector/register.ts subscribe --connector <connector id of the org> --feed tts-skincare-weekly
  • Only the public key reaches the server. A key lives at most 180 days (proposal).
  • subscribe adds the feed key to that connector's config.feeds. The org receives rows only while its market-intelligence plugin is on.
  • One machine is one collector. For a multi-browser crawl, register each machine separately and grant each the same feed.

4. Deliver a week#

mso-collect feeds                                    # granted feeds and the newest promoted window per kind
mso-collect push --feed tts-skincare-weekly --run seat-a:tts-skincare-weekly:2026-11-16 tiktok_product_2026-11-16_2026-11-22.json
mso-collect seal --run seat-a:tts-skincare-weekly:2026-11-16
mso-collect status --run seat-a:tts-skincare-weekly:2026-11-16 --wait   # exit 0 promoted, 2 quarantined or rejected
  • Keep the run id stable for one machine, feed and window: a repeated push resumes the chunks not yet uploaded, and a repeated seal of the same manifest changes nothing.
  • push refuses a capture file with a key outside the known wrapper keys or a week that is not Monday to Sunday; the gateway refuses a window that has not closed in Asia/Ho_Chi_Minh.

If it fails#

Code Meaning Action
stale_timestamp Machine clock more than 300 s off Fix the clock (NTP), retry
key_revoked, key_expired Key no longer valid Register a new key; revoke the old one
feed_not_granted Collector lacks the feed register.ts grant
chunks_mismatch (409 on seal) Missing or differing chunks listed in the reply push again, then seal
quota_exceeded, rate_limited Over a proposal quota The CLI backs off; wait
quarantined Quality gate refused a part; codes in status Read collector_batch_parts.codes; release arrives with the admin page

Revoke a key at once: pnpm tsx scripts/collector/register.ts revoke --key-id <ck_...>; the next request with it is refused.

Rollback#

Unset COLLECTOR_PROMOTE_ENABLED to stop writes, stop the two services, or revoke keys. The tables are additive and read by nothing else. A wrong promote is replaced by delivering the correct capture for that window, or removed with the market-intelligence snapshot delete.