[codex] Keep Mini App tunnel warm#173
Merged
Merged
Conversation
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.
What changed
bux-miniapp-tunnel, a systemd-managed Cloudflare quick tunnel wrapper for the Mini App backend on127.0.0.1:8787./etc/bux/tg.envand restartbux-tgwhen it changes so/agencycan reuse a warm URL.bux-miniappandbux-miniapp-tunnelafter Telegram install, and have/agencyread the URL from process env,tg.env, or the tunnel state file.tg-schedule/tg-schedule-fireand existingagency.dbownership.Why
The current
/agencypath creates a freshtrycloudflare.comtunnel inside the Telegram command handler. On a real bux box this failed withMini App tunnel started but is not reachable yet ([Errno -2] Name or service not known)because the newly minted hostname was not DNS-reachable within the handler timeout.Keeping the tunnel warm moves that fragile work out of the tap path.
/agencycan open a known URL, and the service refreshes the URL when cloudflared restarts.Impact
This is still a tactical quick-tunnel approach, not a named tunnel or cloud-proxy architecture. It should make existing boxes and newly provisioned boxes much more reliable without requiring cloud-side routing changes.
Validation
python3 -m unittest discover agent -p 'test*.py'python3 -m py_compile agent/bux-miniapp-tunnel agent/box_agent.py agent/telegram_bot.py agent/mini_app.py agent/agency_db.pybash -n agent/bootstrap.shgit diff --checkSummary by cubic
Keep the Mini App Cloudflare quick tunnel warm and reuse its public URL so
/agencycan launch reliably. This removes ad‑hoc tunnel creation in the Telegram handler and fixes DNS timing issues on real boxes.New Features
bux-miniapp-tunnelsystemd service that runscloudflaredagainst127.0.0.1:8787./etc/bux/tg.envand/var/lib/bux/miniapp-tunnel/url, and restartsbux-tgwhen it changes./agencyreads the URL fromBUX_MINIAPP_PUBLIC_URL,tg.env, or the tunnel state file;telegram_botwaits briefly for it and starts both services when needed./etc/bux/tg.env.Bug Fixes
tg-schedule/tg-schedule-firesymlinks and fixed ownership for existingagency.db*.Written for commit 3f4df76. Summary will update on new commits.