2 Background Worker
Nate edited this page 2026-11-21 20:21:39 -08:00

Background Worker

Every 60 seconds the worker walks all linked characters: it ensures each access token is usable (refreshing when needed) and re-fetches any snapshot whose cached_until has passed. A first pass runs at boot. It also warms killmail details behind each character's recent list and contract item lists behind the contracts list (both bounded per cycle) so those pages never wait on ESI. The same cycle refreshes the public Intel store (server status, war list and details, incursions, faction-warfare systems/stats, factions) and the public names behind the Intel pages, spending from the same per-cycle lookup budget. It then warms the name caches from the fresh snapshots (type names and type→group links, group names, station/system names, and character names for killmail victims and final-blow attackers) with a small concurrent pool, capped per cycle; a huge account simply converges over a few cycles. Characters are warmed first when they were just linked via SSO or flagged on the Sync page. On a 420/429 the cycle stops and waits for the next tick. Logs stay quiet: one summary line per cycle only when something was refreshed or failed, plus a heartbeat every 10 minutes. The current status (last run, summary, cumulative names resolved) shows on the Admin and Sync pages. When a Trade ideas model is configured (a MODEL_API_KEY, or the Cloudflare credentials as the fallback), the same worker also refreshes the Trade ideas page (Market > Trade ideas): it feeds the spread scanner's Forge rows (at most 60, same columns as the scanner page) to the model and stores the answer, at most twice a day and spending no ESI budget. The call runs beside the worker cycle, not in it; a failed refresh keeps the previous answer and backs off before asking again.