feat: scale core — process split, send outbox, sticky incoming - #12
Merged
Conversation
Keep python main.py as the only start command, but run receive, the RSS circle, and background jobs as child processes so a dead updater no longer restarts Telegram receive. User-triggered rec/update work survives a restart via a leased sqlite outbox, incoming handlers stick to one worker per chat, and shared updater cursor state moves out of gdbm into WAL sqlite.
Patreon writes FSM state, so that watcher stays with receive. flock does not make gdbm safe to share with updater or jobs.
This was referenced Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python main.pyis still the only start/deploy command, but it now supervises bot / updater / jobs as child processes. A crashed RSS circle no longer restarts Telegram receive (supervisorctl restart yourcastunchanged;stopasgroupso the whole tree dies on restart).rec/updatejobs are persisted in a SQLite outbox (pending → leased → done/failed) with lease heartbeat, so a process restart does not drop episode sends. Claim usesBEGIN IMMEDIATE.bot_runtime_kvso gdbm is not the cross-process source of truth. Telethon file session stays bot-only; send workers use StringSession.This composes the useful parts of PR #7 (supervisor) and PR #11 (outbox), plus the blockers those PRs left: import-time send workers in every process, gdbm cursor races, and round-robin incoming races on FSM.
What this is not
senderprocess yet. Automatic circle still sends inline in the updater (proven path). User sends go through the outbox in the bot process.main.py.Test plan
python db/test_send_outbox.py— enqueue/claim/lease/heartbeat/restart/exclusive claimpython db/test_runtime_kv.py— kv, migrate from shelve, updater cannot open file Telethon sessionpython app/core/test_process_supervisor.py— crashed role restarts, sibling pid unchangedpython app/core/balancers/test_sticky.py— sticky + least-loadeddb/test_connection.py,db/test_channel_poll.py,db/test_count_users.py,app/jobs/test_nosub_digest.py,app/service/podcast/test_feed_etag.pypython main.pystarts three children,/startstill works, manual episode send surviveskillof bot child, updater crash does not drop receive