From ef0c0a5e8917fc89c22d8108a9d3bc9f9bdcb7bf Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 2 Oct 2024 11:54:03 +0200 Subject: [PATCH] feat: ensure periodic data updates for app stability Added instructions to README for regularly triggering `/cron/` to keep the app's cached data updated. Modified `main.py` to initialize `global_ibles` even when using a WSGI server, ensuring data consistency. This change improves the reliability and performance of the app by maintaining up-to-date data. Relates to #9 --- README.md | 2 ++ src/structables/main.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 03e3323..711e0cf 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Of course, you can also join our [Matrix room](https://matrix.pcof.fi/#/#structa 4. Run `uwsgi --plugin python3 --http-socket 0.0.0.0:8002 --module structables.main:app --processes 4 --threads 4` 5. Point your reverse proxy to http://localhost:8002 and (optionally) serve static files from the `venv/lib/pythonX.XX/site-packages/structables/static` directory 6. Connect to your instance under your domain +7. Ensure that `/cron/` is executed at regular intervals so that the app updates its cached data. ### Production: Docker @@ -49,6 +50,7 @@ Of course, you can also join our [Matrix room](https://matrix.pcof.fi/#/#structa 4. Point your reverse proxy to http://127.0.0.1:8002 (or your chosen port, if you modified it) and (optionally) serve static files from `structables/static` 5. Connect to your instance under your domain +6. Ensure that `/cron/` is executed at regular intervals so that the app updates its cached data. ### Development diff --git a/src/structables/main.py b/src/structables/main.py index f1a1949..13d952a 100644 --- a/src/structables/main.py +++ b/src/structables/main.py @@ -40,3 +40,6 @@ def main(): if __name__ == "__main__": main() +else: + # Even if we're using a wsgi server, we still have to initialize global_ibles + update_data(app)