From 390a358715d1ecb64d379d2c1bd0cf01afeae1b8 Mon Sep 17 00:00:00 2001 From: Goutte Date: Mon, 12 Mar 2018 12:21:45 +0100 Subject: [PATCH] Add a CRON configuration example to `res/`. Improve the warmup a little. --- res/crontab_example.txt | 5 +++++ web/run.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 res/crontab_example.txt diff --git a/res/crontab_example.txt b/res/crontab_example.txt new file mode 100644 index 0000000..7eb58f0 --- /dev/null +++ b/res/crontab_example.txt @@ -0,0 +1,5 @@ +# Lance la tâche 'clear' pour vider le cache ( dans HELIOPROPA/cache ) toutes les nuits à 2h +0 2 * * * wget -O /dev/null http://heliopropa.irap.omp.eu/cache/clear &> /dev/null + +# Lance la tâche 'warmup' pour remplir le cache ( dans HELIOPROPA/cache ) toutes les nuits à 2h15 +15 2 * * * wget -O /dev/null http://heliopropa.irap.omp.eu/cache/warmup &> /dev/null diff --git a/web/run.py b/web/run.py index 21b0a29..a889b58 100755 --- a/web/run.py +++ b/web/run.py @@ -1163,6 +1163,7 @@ def cache_warmup(): Linked to SpaceWeather#edit in swapp.ls to get the default time interval. If you edit this code you'll need to edit the other as well and vice versa. """ + warmup_started_at = datetime.datetime.now() before = relativedelta(months=2) after = relativedelta(months=1) today = datetime.datetime.now().replace(hour=0, minute=0, second=0) @@ -1179,7 +1180,10 @@ def cache_warmup(): targets_slugs.sort() download_targets_cdf('-'.join(targets_slugs), inp, sta, sto) - return "Done" + warmup_ended_at = datetime.datetime.now() + warmup_timedelta = warmup_ended_at - warmup_started_at + + return "Done in %s." % str(warmup_timedelta) @app.route("/log") -- libgit2 0.21.2