- Add HTTP /health endpoint (aiohttp) for Docker healthcheck + post-deploy check - Dockerfile HEALTHCHECK hits /health; docker-compose exposes 1890, container vision-bot - scripts/deploy_runner.sh runs on .117 (docker compose build/restart) - .forgejo/workflows/deploy.yml: single job on omhk-deploy runner (clone, syntax test, rsync, deploy, health check, auto-rollback) like Kuby - .forgejo/workflows/ci.yml: single job (ruff + pytest) on dev/PR
27 lines
808 B
Python
27 lines
808 B
Python
import logging
|
|
|
|
from aiohttp import web
|
|
|
|
logger = logging.getLogger("vision")
|
|
|
|
|
|
async def start_health_server(port: int, host: str = "0.0.0.0"):
|
|
"""Demarre un mini serveur HTTP expose par le conteneur Docker.
|
|
|
|
Le runner de deploiement interroge /health pour valider le demarrage
|
|
(health check post-deploy, comme Kuby).
|
|
"""
|
|
|
|
async def health(_request: web.Request) -> web.Response:
|
|
return web.Response(text='{"status":"ok"}', content_type="application/json")
|
|
|
|
app = web.Application()
|
|
app.router.add_get("/health", health)
|
|
app.router.add_get("/api/health", health)
|
|
|
|
runner = web.AppRunner(app)
|
|
await runner.setup()
|
|
site = web.TCPSite(runner, host, port)
|
|
await site.start()
|
|
logger.info("Health server demarre sur %s:%s", host, port)
|
|
return runner
|