Skip to content

Commit

Permalink
Add debug to CONFIG and run script
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Mar 5, 2020
1 parent 24637f2 commit 14ef12d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions optimade/server/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
from typing import Any
from configparser import ConfigParser
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 14ef12d

Please sign in to comment.