From fab6199135d75c38f3cdc463884c618784c3655a Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 5 Apr 2023 21:51:32 +0200 Subject: Tweaked suggested way of running web interface --- contrib/waterspout-pull.service | 2 +- contrib/waterspout-web.service | 3 ++- waterspout_radar/web.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/waterspout-pull.service b/contrib/waterspout-pull.service index 509a290..b584688 100644 --- a/contrib/waterspout-pull.service +++ b/contrib/waterspout-pull.service @@ -3,5 +3,5 @@ Description=Pull data for Waterspout Radar [Service] Type=oneshot -ExecStart=/usr/bin/env waterspout-radar -c /etc/waterspout-radar.conf pull +ExecStart=/usr/bin/env waterspout-radar -c /etc/waterspout-radar.conf User=waterspout diff --git a/contrib/waterspout-web.service b/contrib/waterspout-web.service index d177cde..377a221 100644 --- a/contrib/waterspout-web.service +++ b/contrib/waterspout-web.service @@ -3,7 +3,8 @@ Description=Waterspout Radar Web Interface [Service] Type=simple -ExecStart=/usr/bin/env waterspout-radar -c /etc/waterspout-radar.conf web +ExecStart=uwsgi --socket /run/waterspout-radar.sock --module waterspout_radar.web:app --vacuum +Environment="WATERSPOUT_RADAR_CONFIG=/etc/waterspout-radar.conf" User=waterspout [Install] diff --git a/waterspout_radar/web.py b/waterspout_radar/web.py index 37905c3..f43d2c0 100644 --- a/waterspout_radar/web.py +++ b/waterspout_radar/web.py @@ -1,11 +1,12 @@ import flask -from . import _storage +from . import _config, _storage app = flask.Flask(__name__) +config = _config.load(_config.effective_pathname()) @app.route("/") def predictions(): - predictions = sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)) + predictions = sorted(_storage.Storage(config.db), key=lambda x: (x.time, x.swi)) return flask.render_template("predictions.html", predictions=predictions) -- cgit v1.1