Runtime Jobs
Magpie starts several long-running routines on backend startup.
Core routines
- judge refresh routine
- proxy statistics routine
- proxy statistics retention routine
- proxy history routine
- proxy snapshot routine
- proxy geo refresh routine
- orphan cleanup routine
- GeoLite update routine
- blacklist refresh routine
- checker thread dispatcher
- scraper page pool manager
- scraper thread dispatcher
- email delivery routine (durable outbox worker)
- password reset token cleanup routine
Leadership and coordination
Some routines are executed with leader-election semantics using Redis locks to avoid duplicate execution across instances.
The durable email outbox is split across two coordination models:
- Every backend instance runs the email delivery worker and can poll, claim, and send queued outbox rows in parallel.
- Outbox housekeeping remains leader-coordinated to avoid duplicate stale-message recovery and sent-row cleanup work.
Timers
Most intervals are configured in global settings (checker_timer, scraper_timer, judge_timer, blacklist_timer, runtime timers, GeoLite update timer).
Retention routine interval/limits are configured via environment variables:
PROXY_STATISTICS_RETENTION_INTERVAL/PROXY_STATISTICS_RETENTION_INTERVAL_MINUTESPROXY_STATISTICS_RETENTION_DAYSPROXY_STATISTICS_RESPONSE_RETENTION_DAYSPROXY_STATISTICS_RETENTION_BATCH_SIZEPROXY_STATISTICS_RETENTION_MAX_BATCHES
Password recovery maintenance is configured via:
PASSWORD_RESET_CLEANUP_INTERVAL/PASSWORD_RESET_CLEANUP_INTERVAL_MINUTESEMAIL_OUTBOX_POLL_INTERVAL/EMAIL_OUTBOX_POLL_INTERVAL_SECONDSEMAIL_OUTBOX_BATCH_SIZEEMAIL_PROCESSING_TIMEOUT/EMAIL_PROCESSING_TIMEOUT_SECONDSEMAIL_OUTBOX_RETENTION_HOURSEMAIL_RETRY_BASE_SECONDSEMAIL_MAX_ATTEMPTS