mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Merge pull request #1755 from GSA/better_debug
improve debug of external issues
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from flask import Blueprint, jsonify, request
|
from flask import Blueprint, current_app, jsonify, request
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
|
|
||||||
from app import db, version
|
from app import db, version
|
||||||
@@ -11,6 +11,7 @@ status = Blueprint("status", __name__)
|
|||||||
@status.route("/", methods=["GET"])
|
@status.route("/", methods=["GET"])
|
||||||
@status.route("/_status", methods=["GET", "POST"])
|
@status.route("/_status", methods=["GET", "POST"])
|
||||||
def show_status():
|
def show_status():
|
||||||
|
try:
|
||||||
if request.args.get("simple", None):
|
if request.args.get("simple", None):
|
||||||
return jsonify(status="ok"), 200
|
return jsonify(status="ok"), 200
|
||||||
else:
|
else:
|
||||||
@@ -23,10 +24,16 @@ def show_status():
|
|||||||
),
|
),
|
||||||
200,
|
200,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(
|
||||||
|
f"Unexpected error in show_status: {str(e)}", exc_info=True
|
||||||
|
)
|
||||||
|
raise Exception(status_code=503, detail="Service temporarily unavailable")
|
||||||
|
|
||||||
|
|
||||||
@status.route("/_status/live-service-and-organization-counts")
|
@status.route("/_status/live-service-and-organization-counts")
|
||||||
def live_service_and_organization_counts():
|
def live_service_and_organization_counts():
|
||||||
|
try:
|
||||||
return (
|
return (
|
||||||
jsonify(
|
jsonify(
|
||||||
organizations=dao_count_organizations_with_live_services(),
|
organizations=dao_count_organizations_with_live_services(),
|
||||||
@@ -34,9 +41,22 @@ def live_service_and_organization_counts():
|
|||||||
),
|
),
|
||||||
200,
|
200,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(
|
||||||
|
f"Unexpected error in live_service_and_organization_counts: {str(e)}",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
raise Exception(status_code=503, detail="Service temporarily unavailable")
|
||||||
|
|
||||||
|
|
||||||
def get_db_version():
|
def get_db_version():
|
||||||
|
try:
|
||||||
query = "SELECT version_num FROM alembic_version"
|
query = "SELECT version_num FROM alembic_version"
|
||||||
full_name = db.session.execute(text(query)).fetchone()[0]
|
full_name = db.session.execute(text(query)).fetchone()[0]
|
||||||
return full_name
|
return full_name
|
||||||
|
except Exception as e:
|
||||||
|
current_app.logger.error(
|
||||||
|
f"Unexpected error in get_db_version: {str(e)}",
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
raise Exception(status_code=503, detail="Database temporarily unavailable")
|
||||||
|
|||||||
Reference in New Issue
Block a user