Skip to content

Commit 908b9fe

Browse files
committed
noninvasive cabotge support
1 parent 85064e1 commit 908b9fe

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
COPY requirements.txt .
5+
RUN pip install --no-cache-dir -r requirements.txt
6+
COPY bedevere bedevere
7+
8+
CMD ["python", "-m", "bedevere"]

bedevere/__main__.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,30 @@ async def repo_installation_added(event, gh, *args, **kwargs):
6868
)
6969

7070

71+
async def health_check(request):
72+
"""Health check endpoint for container orchestration."""
73+
return web.Response(status=200, text="OK")
74+
75+
7176
if __name__ == "__main__": # pragma: no cover
7277
app = web.Application()
7378
app.router.add_post("/", main)
79+
app.router.add_get("/health", health_check)
80+
81+
socket_path = os.environ.get("SOCKET_PATH")
7482
port = os.environ.get("PORT")
75-
if port is not None:
76-
port = int(port)
77-
web.run_app(app, port=port)
83+
84+
if socket_path:
85+
86+
async def run_with_socket():
87+
runner = web.AppRunner(app)
88+
await runner.setup()
89+
site = web.UnixSite(runner, path=socket_path)
90+
await site.start()
91+
await asyncio.Event().wait()
92+
93+
asyncio.run(run_with_socket())
94+
else:
95+
if port is not None:
96+
port = int(port)
97+
web.run_app(app, port=port)

0 commit comments

Comments
 (0)