diff --git a/optimade/server/config.py b/optimade/server/config.py index c7639c46c..260a5ba3f 100644 --- a/optimade/server/config.py +++ b/optimade/server/config.py @@ -1,3 +1,4 @@ +import os import json from typing import Any from configparser import ConfigParser @@ -19,6 +20,7 @@ class Config: _path: Path = Path(__file__).parent.joinpath("config.ini") def __init__(self, server_cfg: Path = None): + self._debug = os.getenv("DEBUG") == "1" self._server = ( Path().resolve().joinpath("server.cfg") if server_cfg is None @@ -88,6 +90,14 @@ def load(self, ftype: str = None): else: f() + @property + def debug(self): + return self._debug + + @debug.setter + def debug(self, _): + raise AttributeError("debug cannot be set") + class ServerConfig(Config): """ This class stores server config parameters in a way that diff --git a/run.sh b/run.sh index bee1a0a3f..e49535e87 100755 --- a/run.sh +++ b/run.sh @@ -1,9 +1,15 @@ #!/bin/bash -set -ex + +if [ "$1" == "debug" ]; then + export DEBUG=1 +fi if [ "$1" == "index" ]; then MAIN="main_index" PORT=5001 + if [ "$2" == "debug" ]; then + export DEBUG=1 + fi else if [ "${MAIN}" == "main_index" ]; then PORT=5001