From ab393e5d237d86e66d1f67398370c46dc053b1fe Mon Sep 17 00:00:00 2001 From: Helena Date: Mon, 18 Sep 2023 11:31:36 +0200 Subject: [PATCH 1/2] Update apolpi.py --- apolpi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apolpi.py b/apolpi.py index 9da4b10..dd2e791 100644 --- a/apolpi.py +++ b/apolpi.py @@ -9,8 +9,10 @@ global CACHED_RESULT global CACHED_TIME +global TIMEOUT CACHED_RESULT = None CACHED_TIME = 0 +TIMEOUT = int(os.environ.get('TIMEOUT', 30)) app = Flask(__name__) @@ -113,7 +115,7 @@ def doit(): global CACHED_TIME global CACHED_RESULT now = time.time() - if now - CACHED_TIME > 30: + if now - CACHED_TIME > TIMEOUT: CACHED_RESULT = _fetch() CACHED_TIME = now From 418a0b6394d5f990d491b88fc3330d2f608d508f Mon Sep 17 00:00:00 2001 From: Helena Date: Mon, 18 Sep 2023 11:34:22 +0200 Subject: [PATCH 2/2] Expose timeout in dockerfile Not really necessary tbh --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 7e40a98..e0c283c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ COPY apolpi.py boot.sh ./ RUN chmod +x boot.sh ENV FLASK_APP apolpi.py +ENV TIMEOUT 30 EXPOSE 80 ENTRYPOINT ["/apolpi/boot.sh"]