refactor: Remove deprecated INTERNAL_API_PORT (ultrathin monolith cleanup)

Architecture cleanup after migration to ultrathin monolith:

- Remove INTERNAL_API_PORT from .env files (was port 8002)
- Clean up bot_main.py: remove uvicorn, Thread, run_internal_api()
- Update validate.md to check /api/telegram/health instead of port 8002
- Add deprecation notices to old Windows deployment docs
- Update docs/telegram/README.md with architecture note

The Telegram internal API is now served at /api/telegram/internal/*
on the main backend port (8000/8001) instead of separate port 8002.

Also includes: menu updates, ServerLogsView improvements, script fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-04 03:56:27 +02:00
parent 1e244eefea
commit f1f6760bef
16 changed files with 96 additions and 85 deletions

View File

@@ -143,7 +143,7 @@ TELEGRAM_BOT_TOKEN=your_bot_token_from_botfather
BACKEND_URL=http://localhost:8000
# Internal API port (bot's internal API for backend callbacks)
INTERNAL_API_PORT=8002
# INTERNAL_API_PORT=8002 # DEPRECATED: Now served via main app at /api/telegram/internal/*
# Enable internal API documentation (development only)
ENABLE_DOCS=false

View File

@@ -137,7 +137,7 @@ TELEGRAM_BOT_TOKEN=your_bot_token_from_botfather
BACKEND_URL=http://localhost:8000
# Internal API port (bot's internal API for backend callbacks)
INTERNAL_API_PORT=8002
# INTERNAL_API_PORT=8002 # DEPRECATED: Now served via main app at /api/telegram/internal/*
# Enable internal API documentation (DISABLE in production!)
ENABLE_DOCS=false

View File

@@ -144,7 +144,7 @@ TELEGRAM_BOT_TOKEN=8483383555:AAGNY1z6WiBkvVfy1ZV_gM_JnAqW4q4MlEY
BACKEND_URL=http://localhost:8000
# Internal API port (bot's internal API for backend callbacks)
INTERNAL_API_PORT=8002
# INTERNAL_API_PORT=8002 # DEPRECATED: Now served via main app at /api/telegram/internal/*
# Enable internal API documentation (development only)
ENABLE_DOCS=false

View File

@@ -10,8 +10,7 @@ import logging
import os
from pathlib import Path
from dotenv import load_dotenv
import uvicorn
from threading import Thread
# Note: uvicorn and threading removed - internal API now served via main.py
# ============================================================================
# LOAD ENVIRONMENT VARIABLES FIRST - BEFORE ANY APP IMPORTS
@@ -69,8 +68,7 @@ from backend.modules.telegram.bot.handlers import (
# Import email authentication handler
from backend.modules.telegram.bot.email_handlers import email_login_handler
# Import internal API
from backend.modules.telegram.internal_api import internal_api
# Note: internal_api import removed - now served via main.py at /api/telegram/internal/*
# Configure logging
logging.basicConfig(
@@ -82,7 +80,7 @@ logger = logging.getLogger(__name__)
# Environment variables (already loaded above)
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')
BACKEND_URL = os.getenv('BACKEND_URL', 'http://localhost:8000')
INTERNAL_API_PORT = int(os.getenv('INTERNAL_API_PORT', '8002'))
# Note: INTERNAL_API_PORT removed - internal API now served via main.py
# ============================================================================
@@ -153,29 +151,10 @@ def create_telegram_application() -> Application:
return application
# ============================================================================
# INTERNAL API SERVER
# ============================================================================
def run_internal_api():
"""
Run the internal FastAPI server in a separate thread.
This API handles communication from the backend (saving auth codes).
"""
logger.info(f"Starting internal API on port {INTERNAL_API_PORT}...")
uvicorn.run(
internal_api,
host="0.0.0.0",
port=INTERNAL_API_PORT,
log_level="info"
)
# ============================================================================
# STARTUP/SHUTDOWN
# ============================================================================
# Note: Internal API server removed - now served via main.py at /api/telegram/internal/*
async def startup():
"""
@@ -247,10 +226,7 @@ async def main():
# Create Telegram application
telegram_app = create_telegram_application()
# Start internal API in a separate thread
api_thread = Thread(target=run_internal_api, daemon=True)
api_thread.start()
logger.info(f"✅ Internal API started on port {INTERNAL_API_PORT}")
# Note: Internal API server removed - now served via main.py
# Start scheduled cleanup task in background
cleanup_task = asyncio.create_task(scheduled_cleanup())