feat: Auto-sync credentials on startup
- Import credential_manager - Call sync_credentials() on FastAPI startup event - Print sync status in logs
This commit is contained in:
18
main.py
18
main.py
@@ -12,6 +12,7 @@ import audio_handler
|
|||||||
|
|
||||||
from ai_agent import query_agent
|
from ai_agent import query_agent
|
||||||
from config import get_config, save_config
|
from config import get_config, save_config
|
||||||
|
from credential_manager import sync_credentials
|
||||||
|
|
||||||
# Carrega as variáveis do .env
|
# Carrega as variáveis do .env
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@@ -21,6 +22,23 @@ app = FastAPI(title="VpsTelegramBot API")
|
|||||||
# Configura templates HTML
|
# Configura templates HTML
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# AUTO-SYNC DE CREDENCIAIS NO STARTUP
|
||||||
|
# ============================================================
|
||||||
|
print("[INIT] Sincronizando credenciais...")
|
||||||
|
sync_result = sync_credentials()
|
||||||
|
print(f"[INIT] Credenciais sincronizadas: {sync_result['status']}")
|
||||||
|
print(f"[INIT] Services: {', '.join(sync_result['services'].keys())}")
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# EVENTO DE STARTUP
|
||||||
|
# ============================================================
|
||||||
|
@app.on_event("startup")
|
||||||
|
async def startup_event():
|
||||||
|
print("[STARTUP] Sincronizando credenciais...")
|
||||||
|
sync_credentials()
|
||||||
|
print("[STARTUP] Credenciais sincronizadas com sucesso!")
|
||||||
|
|
||||||
# --- SEGURANÇA ---
|
# --- SEGURANÇA ---
|
||||||
async def verify_password(x_web_password: str = Header(None)):
|
async def verify_password(x_web_password: str = Header(None)):
|
||||||
cfg = get_config()
|
cfg = get_config()
|
||||||
|
|||||||
Reference in New Issue
Block a user