Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a health check path for render #106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ services:
dockerfilePath: Dockerfile.render
plan: free # optional; defaults to starter
numInstances: 1
healthCheckPath: /health-check
3 changes: 2 additions & 1 deletion sympy_bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

from aiohttp import web

from .webapp import main_get, main_post
from .webapp import main_get, main_post, main_health_check

if __name__ == "__main__":
app = web.Application()
app.router.add_post("/", main_post)
app.router.add_get("/", main_get)
app.router.add_get("/health-check", main_health_check)
port = os.environ.get("PORT")
if port is not None:
port = int(port)
Expand Down
4 changes: 4 additions & 0 deletions sympy_bot/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ async def main_get(request):

return web.Response(status=200, text=f"SymPy Bot has {remaining} of {total} GitHub API requests remaining. They will reset on {reset_datetime} (UTC), which is in {reset_datetime - datetime.datetime.now(datetime.timezone.utc)}.")

async def main_health_check(request):
print("Health check")
return web.Response(status=200, text="OK")

@router.register("pull_request", action="opened")
@router.register("pull_request", action="reopened")
@router.register("pull_request", action="edited")
Expand Down