Merge branch 'health_check' of DigiFi/digifi-BankEmulator into master

This commit is contained in:
2025-06-28 13:50:03 +00:00
committed by Gogs
5 changed files with 87 additions and 2 deletions
+31 -2
View File
@@ -1,4 +1,5 @@
from flask import Flask, Blueprint, request, jsonify, send_from_directory
import sys
import os
from app.api.services import (
RACCheckService,
@@ -16,6 +17,7 @@ from app.utils.logger import logger
from app.api.middlewares import require_api_key, require_app_id, enforce_json
api = Blueprint("api", __name__)
@@ -162,7 +164,34 @@ def new_transaction_check():
response = NewTransactionCheckService.process_request(data)
return response
# Health Check Endpoint
@api.route('/health', methods=['GET'])
@api.route('/system-health-check', methods=['GET'])
def health_check():
return {"status": "ok"} , 200
"""Basic system health check"""
try:
checks = {
"python_version": sys.version_info >= (3, 6),
"disk_space": os.statvfs('/').f_bavail * os.statvfs('/').f_frsize > 500 * 1024 * 1024,
"system_operational": True
}
if all(checks.values()):
return jsonify({
"status": "Active",
"responseCode": "00",
"responseMessage": "Successful"
}), 200
else:
return jsonify({
"status": "Degraded",
"responseCode": "01",
"responseMessage": "System check failed"
}), 200
except Exception as e:
return jsonify({
"status": "Error",
"responseCode": "99",
"responseMessage": f"Health check failed: {str(e)}"
}), 500
+3
View File
@@ -110,6 +110,9 @@
}
],
"paths": {
"/api/system-health-check": {
"$ref": "swagger/paths/HealthCheck.json"
},
"/api/rac-check": {
"$ref": "swagger/paths/RACCheck.json"
},
+19
View File
@@ -0,0 +1,19 @@
{
"get": {
"tags": ["System"],
"summary": "System Health Check",
"description": "Returns the current health status of the system",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/HealthCheckResponse.json"
}
}
}
}
}
}
}
@@ -0,0 +1,17 @@
{
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "Active"
},
"responseCode": {
"type": "string",
"example": "00"
},
"responseMessage": {
"type": "string",
"example": "Successful"
}
}
}
@@ -0,0 +1,17 @@
{
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "Active"
},
"responseCode": {
"type": "string",
"example": "00"
},
"responseMessage": {
"type": "string",
"example": "Successful"
}
}
}