Baptiste Beauplat pushed to branch master at snapshot / snapshot
Commits:
-
8a5acef6
by Philipp Kern at 2025-04-26T19:41:55+02:00
-
887b86f9
by Philipp Kern at 2025-04-26T19:42:31+02:00
-
e8d50356
by Baptiste Beauplat at 2025-04-27T10:11:20+02:00
2 changed files:
Changes:
... | ... | @@ -57,8 +57,8 @@ trixie: |
57 | 57 | image: debian:trixie
|
58 | 58 | variables:
|
59 | 59 | ADDITIONAL_PACKAGES:
|
60 | - postgresql-15-debversion
|
|
61 | - postgresql-plperl-15
|
|
60 | + postgresql-17-debversion
|
|
61 | + postgresql-plperl-17
|
|
62 | 62 | |
63 | 63 | bookworm:
|
64 | 64 | <<: *test
|
... | ... | @@ -23,8 +23,10 @@ |
23 | 23 | |
24 | 24 | from logging import getLogger
|
25 | 25 | from urllib.parse import quote
|
26 | +import os
|
|
26 | 27 | |
27 | -from flask import Blueprint, render_template, request, current_app
|
|
28 | +from flask import Blueprint, render_template, request, current_app, \
|
|
29 | + make_response
|
|
28 | 30 | |
29 | 31 | from snapshot.lib.control_helpers import link_quote_array, get_domain
|
30 | 32 | from snapshot.lib.cache import cache
|
... | ... | @@ -58,6 +60,24 @@ def oldnews(): |
58 | 60 | return render_template('root/misc-oldnews.html', breadcrumbs=breadcrumbs)
|
59 | 61 | |
60 | 62 | |
63 | +def health_check():
|
|
64 | + if os.path.exists('/run/systemd/shutdown/scheduled'):
|
|
65 | + return 'Reboot pending', 503
|
|
66 | + try:
|
|
67 | + get_snapshot_model().archives_get_list()
|
|
68 | + except Exception:
|
|
69 | + return 'No database', 503
|
|
70 | + return 'OK', 200
|
|
71 | + |
|
72 | + |
|
73 | +@router.route("/healthz")
|
|
74 | +def healthz():
|
|
75 | + response = make_response(*health_check())
|
|
76 | + response.mimetype = 'text/plain'
|
|
77 | + response.headers['Cache-Control'] = 'private, no-store'
|
|
78 | + return response
|
|
79 | + |
|
80 | + |
|
61 | 81 | def _build_crumbs(page=None):
|
62 | 82 | crumbs = []
|
63 | 83 |