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"] 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