Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Add simple health check endpoint to determine API accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rita committed Sep 19, 2022
1 parent ece3ccc commit 0ed8991
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions API/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .download_export import router as download_router
from .test_router import router as test_router
from .status import router as status_router
from .system import router as health_router
from fastapi import Request
from fastapi.responses import JSONResponse
from src.galaxy.db_session import database_instance
Expand Down Expand Up @@ -71,6 +72,7 @@
app.include_router(tm_router)
app.include_router(status_router)
app.include_router(raw_data_router)
app.include_router(health_router)
if use_s3_to_upload is False : # only mount the disk if config is set to disk
app.include_router(download_router)

Expand Down
42 changes: 42 additions & 0 deletions API/system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) 2021 Humanitarian OpenStreetmap Team

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# Humanitarian OpenStreetmap Team
# 1100 13th Street NW Suite 800 Washington, D.C. 20005
# <[email protected]>

"""
Router Responsible for Checking API Health
"""

from fastapi import APIRouter
from fastapi_versioning import version

router = APIRouter(prefix="/system")

@router.get("/health/")
@version(1)
def check_system_health():
"""Simple health check for API accessibility
Returns:
{
"status": "healthy"
}
"""
return {"status": "healthy"}


2 changes: 0 additions & 2 deletions src/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,5 +1273,3 @@ def __call__(self, bytes_amount):
self._seen_so_far += bytes_amount
percentage = (self._seen_so_far / self._size) * 100
logging.debug("\r%s %s / %s (%.2f%%)" ,self._filename, self._seen_so_far, self._size,percentage)


0 comments on commit 0ed8991

Please sign in to comment.