aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Garrett <dylan.garrett@gmail.com>2021-06-15 21:46:00 -0700
committerDylan Garrett <dylan.garrett@gmail.com>2021-06-15 21:46:00 -0700
commite7f4b527e2ee2cbae9f7a53f2a8100fa40bc9138 (patch)
tree2cad90e05483e1b9eeeff827739b41244266938b
parent5e11f94aabd7acb4346739d6235050feced28a11 (diff)
downloadroka-e7f4b527e2ee2cbae9f7a53f2a8100fa40bc9138.tar.gz
roka-e7f4b527e2ee2cbae9f7a53f2a8100fa40bc9138.zip
Load config outside of main to keep uwsgi working
-rwxr-xr-xroka.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/roka.py b/roka.py
index 5729454..252ade9 100755
--- a/roka.py
+++ b/roka.py
@@ -11,6 +11,10 @@ from lib.util import check_auth, escape, generate_rss, read_cache
abs_path = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__)
+config_path = os.path.join(abs_path, 'app.cfg')
+config_exists = os.path.exists(config_path)
+if config_exists or __name__.startswith('uwsgi'):
+ app.config.from_pyfile(config_path)
cache_path = os.path.join(abs_path, 'cache')
json_path = os.path.join(cache_path, 'audiobooks.json')
@@ -108,9 +112,10 @@ if __name__ == '__main__':
def __init__(self, d):
self.__dict__ = d
config = objectview(json.loads(args.config))
+ # override app.cfg
app.config.from_object(config)
- else:
- app.config.from_pyfile(os.path.join(abs_path, 'app.cfg'))
+ elif not config_exists:
+ raise Exception(f"Config file '{config_path}' doesn't exist")
root_path = os.path.expanduser(app.config['ROOT_PATH'])