morshu-server: report startup errors in Discord
This commit is contained in:
+13
-17
@@ -516,21 +516,19 @@ class TtsToy(Cog):
|
||||
except Exception as e:
|
||||
log.exception(f"Error stopping DECTalk server: {e}")
|
||||
|
||||
async def _start_morshu_server(self) -> bool:
|
||||
"""Start the built-in Morshu TTS server."""
|
||||
async def _start_morshu_server(self) -> tuple:
|
||||
"""Start the built-in Morshu TTS server. Returns (success, error_msg)."""
|
||||
try:
|
||||
if self.morshu_process and self.morshu_process.poll() is None:
|
||||
log.info("Morshu server already running")
|
||||
return True
|
||||
return True, None
|
||||
|
||||
if not self.morshu_dir.exists():
|
||||
log.error(f"Morshu server directory not found: {self.morshu_dir}")
|
||||
return False
|
||||
return False, f"Directory not found: {self.morshu_dir}"
|
||||
|
||||
server_py = self.morshu_dir / "server.py"
|
||||
if not server_py.exists():
|
||||
log.error(f"Morshu server not found: {server_py}")
|
||||
return False
|
||||
return False, f"server.py not found: {server_py}"
|
||||
|
||||
env = os.environ.copy()
|
||||
env['PORT'] = str(self.morshu_port)
|
||||
@@ -552,18 +550,15 @@ class TtsToy(Cog):
|
||||
if self.morshu_process.poll() is not None:
|
||||
stderr = self.morshu_process.stderr.read()
|
||||
stdout = self.morshu_process.stdout.read()
|
||||
log.error(f"Morshu server failed to start (exit {self.morshu_process.returncode})")
|
||||
if stderr:
|
||||
log.error(f"Morshu stderr: {stderr}")
|
||||
if stdout:
|
||||
log.error(f"Morshu stdout: {stdout}")
|
||||
return False
|
||||
err = stderr or stdout or "Unknown error"
|
||||
log.error(f"Morshu server failed (exit {self.morshu_process.returncode}): {err}")
|
||||
return False, err
|
||||
|
||||
log.info(f"Morshu server started on port {self.morshu_port}")
|
||||
return True
|
||||
return True, None
|
||||
except Exception as e:
|
||||
log.exception(f"Failed to start Morshu server: {e}")
|
||||
return False
|
||||
return False, str(e)
|
||||
|
||||
async def _stop_morshu_server(self):
|
||||
"""Stop the built-in Morshu server."""
|
||||
@@ -2140,7 +2135,7 @@ class TtsToy(Cog):
|
||||
"""Start the built-in Morshu TTS server."""
|
||||
await ctx.send("🚀 Starting Morshu server...")
|
||||
|
||||
success = await self._start_morshu_server()
|
||||
success, error = await self._start_morshu_server()
|
||||
|
||||
if success:
|
||||
await ctx.send(
|
||||
@@ -2148,7 +2143,8 @@ class TtsToy(Cog):
|
||||
f"Switch to Morshu mode: `{ctx.clean_prefix}ttstoy mode morshu`"
|
||||
)
|
||||
else:
|
||||
await ctx.send("❌ Failed to start Morshu server. Check bot logs.")
|
||||
err_msg = (error or "Unknown error")[:1500]
|
||||
await ctx.send(f"❌ Failed to start Morshu server:\n```\n{err_msg}\n```")
|
||||
|
||||
@ttstoy_group.command(name="morshustop")
|
||||
@commands.is_owner()
|
||||
|
||||
Reference in New Issue
Block a user