fix: route webui internal callbacks to localhost

The bot posts job-status updates and login-token registration to the
public webui URL (ttstoy.kingstons-scrapyard.net) with a 5s timeout.
Under load, that WAN hop times out and jobs stay stuck 'pending' even
though audio was generated. Since the webui runs as a child process of
the bot on the same host, use http://127.0.0.1:8098 for these
server-to-server callbacks instead.
This commit is contained in:
owen
2026-09-12 22:00:29 -05:00
parent 9c0f0fac4f
commit 53cf544680
+6 -2
View File
@@ -3018,6 +3018,10 @@ class TtsToy(Cog):
state = self._read_shared_state()
return state.get("webui_url", os.environ.get("WEBUI_URL", "https://ttstoy.kingstons-scrapyard.net"))
def _get_webui_internal_url(self) -> str:
port = os.environ.get("WEBUI_PORT", "8098")
return f"http://127.0.0.1:{port}"
def _get_internal_secret(self) -> str:
state = self._read_shared_state()
return state.get("internal_secret", "")
@@ -3026,7 +3030,7 @@ class TtsToy(Cog):
@commands.guild_only()
async def webui_login(self, ctx: commands.Context):
"""Get a one-time login key for Kingston's Scrapyard. Must be used in a server so the key knows which server you're in. The key is DM'd to you."""
webui_url = self._get_webui_url()
webui_url = self._get_webui_internal_url()
secret = self._get_internal_secret()
if not secret:
return await ctx.send(
@@ -3253,7 +3257,7 @@ class TtsToy(Cog):
guild_id_str = payload.get("guild_id", "")
log.info(f"[WebUI] speak_in_vc: user={user} job={job_id} guild={guild_id_str} mode_override={mode_override} voice_override={voice_override} skip_vc={skip_vc} skip_post={skip_post} text={text[:60]!r}")
webui_url = self._get_webui_url()
webui_url = self._get_webui_internal_url()
secret = self._get_internal_secret()
def _update_job(status, **kwargs):