Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lucbellicaud committed Oct 17, 2024
2 parents 6174ea0 + 8c37be4 commit cf74a53
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.9.0](https://github.com/Seven-of-Di/ben/compare/v0.8.0...v0.9.0) (2024-06-26)
### [0.9.4](https://github.com/Seven-of-Di/ben/compare/v0.9.3...v0.9.4) (2024-10-01)


### Bug Fixes

* Parenthesis fix, Lia was accepting the claim too agressively ([e4a5ba2](https://github.com/Seven-of-Di/ben/commit/e4a5ba2b2c7b894270f3f7141094cc887fc63aa2))
* revert to simple http healthcheck ([b7e747b](https://github.com/Seven-of-Di/ben/commit/b7e747b885379862229c58bc280e3cd523b1be56))
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.4
2 changes: 0 additions & 2 deletions src/health_checker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import psutil
import threading
from typing import List
import logging

class HealthChecker:
cpu_usage: List[float]
Expand All @@ -12,7 +11,6 @@ def __init__(self) -> None:
def healthy(self) -> bool:
for cpu_per_core in self.cpu_usage:
if cpu_per_core > 95:
logging.warning(self.cpu_usage)
return False

return True
Expand Down
18 changes: 10 additions & 8 deletions src/starlette_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from starlette.responses import JSONResponse
from starlette.routing import Route
from starlette.requests import Request
from starlette.responses import Response
from starlette.middleware.base import BaseHTTPMiddleware
from opentelemetry import trace
from starlette_exporter import PrometheusMiddleware, handle_metrics, CollectorRegistry, multiprocess # type: ignore
Expand Down Expand Up @@ -75,7 +76,6 @@ def __init__(self, play_card_request):
self.playing_mode = PlayingMode.from_str(play_card_request[
"playing_mode"]) if "playing_mode" in play_card_request else PlayingMode.MATCHPOINTS


class MakeLead:
def __init__(self, make_lead_request):
self.hand = make_lead_request['hand']
Expand Down Expand Up @@ -261,14 +261,16 @@ async def alert_bid(request: Request):
logging.exception(e)
return {'error': str(e)},500

health_checker = HealthChecker()
# health_checker = HealthChecker()
# health_checker.start()

async def healthz():
healthy = health_checker.healthy()
if healthy:
return 'ok', 200
async def healthz(_: Request):
return Response("OK", status_code=200)
# healthy = health_checker.healthy()
# if healthy:
# return Response("OK", status_code=200)

return 'unhealthy', 500
# return Response("FAILURE", status_code=500)

class TracingHeaderMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request, call_next):
Expand Down Expand Up @@ -314,7 +316,7 @@ async def dispatch(self, request, call_next):
Route('/check_claim', check_claim, methods=['POST']),
Route('/play_full_board', play_full_board, methods=['POST']),
Route('/alert_bid', alert_bid, methods=['POST']),
# Route('/healthz', healthz, methods=['GET'])
Route('/healthz', healthz, methods=['GET'])
],
middleware=[
Middleware(OpenTelemetryMiddleware),
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.9.0"
"version": "0.9.4"
}

0 comments on commit cf74a53

Please sign in to comment.