diff --git a/backend/admin/router.py b/backend/admin/router.py index 450c30a..6af0cf6 100644 --- a/backend/admin/router.py +++ b/backend/admin/router.py @@ -44,15 +44,17 @@ async def deploy(request: Request): project_path = settings.deploy_project_path cmd = ( + f"sleep 3 && " f"git config --global --add safe.directory {project_path} && " f"cd {project_path} && " f"git fetch origin main && " f"git reset --hard origin/main && " f"docker-compose up -d --build" + f" > /proc/1/fd/1 2>&1" ) - # Fire and forget — run deploy in background so we can respond before - # the container restarts (which would kill this very process). + # Fire and forget — sleep gives uvicorn time to flush the HTTP response + # before docker-compose tears down and restarts this container. await asyncio.create_subprocess_shell( cmd, stdout=asyncio.subprocess.DEVNULL, @@ -60,5 +62,5 @@ async def deploy(request: Request): start_new_session=True, ) - logger.info("Auto-deploy started in background") + logger.info("Auto-deploy queued (starts in 3s)") return {"ok": True, "message": "Deploy started"}