guardia-manager/backend/routers/deploy.py
DESKTOP-TKLFCPRython 10cc76d6e6 refactor: 101.79.17.164 → zioinfo.co.kr 전체 도메인 변환 + Manager UI 배포
- 37개 파일 IP → zioinfo.co.kr 치환 (소스/매뉴얼/설정/하네스)
- Manager DrConsole/NetworkConsole/CsapConsole 빌드 + /var/www/manager/ 배포
- 테스트: Manager HTTP 200, ITSM 신규 API 7개 전체 200

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 10:09:17 +09:00

28 lines
1.1 KiB
Python

import httpx, os
from fastapi import APIRouter, Depends, HTTPException
from core.auth import verify_token
router = APIRouter()
WEBHOOK_URL = os.environ.get("DEPLOY_WEBHOOK", "http://localhost:9999/")
DEPLOY_LOG = os.environ.get("DEPLOY_LOG", "/var/log/zioinfo/deploy.log")
@router.post("/trigger/{repo}")
async def trigger(repo: str, user=Depends(verify_token)):
async with httpx.AsyncClient() as c:
try:
r = await c.post(WEBHOOK_URL,
json={"repo": repo, "triggered_by": user.get("sub", "manager")},
timeout=10)
return {"status": r.status_code, "message": f"{repo} 배포 트리거됨"}
except Exception as e:
raise HTTPException(status_code=502, detail=f"Deploy Webhook 연결 실패: {e}")
@router.get("/history")
async def history(_=Depends(verify_token)):
try:
with open(DEPLOY_LOG, encoding="utf-8", errors="replace") as f:
lines = f.readlines()[-200:]
return {"lines": [l.rstrip() for l in lines]}
except FileNotFoundError:
return {"lines": []}