Skip to content

Commit b780dd9

Browse files
feat: add health check
1 parent 6ca981f commit b780dd9

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ EXPOSE 8080
5353

5454
# Add healthcheck
5555
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
56-
CMD curl -f http://localhost:8080/ || exit 1
56+
CMD curl -f http://localhost:8080/health || exit 1
5757

5858
# Set the default command to run the application
59-
CMD ["python", "main.py"]
59+
CMD ["poetry", "run", "python", "app.py"]

app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def init_app():
3939
init_routes()
4040

4141
# Mount the static directory
42-
app.mount("/static", StaticFiles(directory="static"), name="static")
42+
app.add_static_files('/static', 'static')
43+
#app.mount("/static", StaticFiles(directory="static"), name="static")
4344

4445
return app
4546

helm/bingo/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ spec:
6565
protocol: TCP
6666
livenessProbe:
6767
httpGet:
68-
path: /
68+
path: /health
6969
port: http
7070
initialDelaySeconds: 30
7171
periodSeconds: 10
7272
readinessProbe:
7373
httpGet:
74-
path: /
74+
path: /health
7575
port: http
7676
initialDelaySeconds: 5
7777
periodSeconds: 5

src/ui/board_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from typing import Callable, cast
66

7-
from nicegui import ui
7+
from nicegui import ui, app
88

99
from src.config.constants import (
1010
BOARD_TILE_FONT,
@@ -207,6 +207,7 @@ def on_phrases_change(phrases):
207207
check_timer = ui.timer(
208208
1, lambda: check_phrases_file_change(on_phrases_change)
209209
)
210+
app.on_disconnect(check_timer.cancel)
210211
except Exception as e:
211212
logging.warning(f"Error setting up timer: {e}")
212213

@@ -218,3 +219,4 @@ def on_phrases_change(phrases):
218219
local_tile_buttons: TileButtonsDict = {}
219220
build_board(container, local_tile_buttons, toggle_tile, board, clicked_tiles)
220221
board_views["stream"] = (container, local_tile_buttons)
222+

src/ui/routes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import logging
66

7-
from nicegui import ui
7+
from nicegui import ui, app
88

99
from src.config.constants import HOME_BG_COLOR, STREAM_BG_COLOR
1010
from src.ui.board_builder import create_board_view
@@ -20,6 +20,7 @@ def home_page():
2020
try:
2121
# Create a timer that deactivates when the client disconnects
2222
timer = ui.timer(0.1, sync_board_state)
23+
app.on_disconnect(timer.cancel)
2324
except Exception as e:
2425
logging.warning(f"Error creating timer: {e}")
2526

@@ -33,9 +34,14 @@ def stream_page():
3334
try:
3435
# Create a timer that deactivates when the client disconnects
3536
timer = ui.timer(0.1, sync_board_state)
37+
app.on_disconnect(timer.cancel)
3638
except Exception as e:
3739
logging.warning(f"Error creating timer: {e}")
3840

41+
@app.get("/health")
42+
def health():
43+
return {'health': 'ok'}
44+
3945

4046
def init_routes():
4147
"""

0 commit comments

Comments
 (0)