diff --git a/quarry/web/app.py b/quarry/web/app.py index 1da807a..fbd69e0 100644 --- a/quarry/web/app.py +++ b/quarry/web/app.py @@ -24,9 +24,14 @@ def get_config(): conf = {} - conf.update( - yaml.safe_load(open(os.path.join(__dir__, "/config/config.yaml"))) - ) + if os.path.isfile("/config/config.yaml"): + # k8s + config_path = "/config/config.yaml" + elif os.path.isfile("../config.yaml"): + # VM + config_path = "../config.yaml" + + conf.update(yaml.safe_load(open(os.path.join(__dir__, config_path)))) return conf diff --git a/quarry/web/killer.py b/quarry/web/killer.py index 5c72ec7..54137c7 100755 --- a/quarry/web/killer.py +++ b/quarry/web/killer.py @@ -6,7 +6,17 @@ from connections import Connections __dir__ = os.path.dirname(__file__) -config = yaml.safe_load(open(os.path.join(__dir__, "/config/config.yaml"))) +if os.path.isfile("/config/config.yaml"): + # k8s + config_path = "/config/config.yaml" +elif os.path.isfile("../config.yaml"): + # VM + config_path = "../config.yaml" +else: + # test + config_path = "../default_config.yaml" + +config = yaml.safe_load(open(os.path.join(__dir__, config_path))) logging.basicConfig( filename=config["KILLER_LOG_PATH"], diff --git a/quarry/web/worker.py b/quarry/web/worker.py index bbd4fdc..66e9f16 100644 --- a/quarry/web/worker.py +++ b/quarry/web/worker.py @@ -22,16 +22,18 @@ celery_log = get_task_logger(__name__) celery = Celery("quarry.web.worker") -try: - celery.conf.update( - yaml.safe_load(open(os.path.join(__dir__, "/config/config.yaml"))) - ) -except IOError: + +if os.path.isfile("/config/config.yaml"): + # k8s + config_path = "/config/config.yaml" +elif os.path.isfile("../config.yaml"): + # VM + config_path = "../config.yaml" +else: # for pytest - celery.conf.update( - yaml.safe_load(open(os.path.join(__dir__, "../default_config.yaml"))) - ) - pass + config_path = "../default_config.yaml" + +celery.conf.update(yaml.safe_load(open(os.path.join(__dir__, config_path)))) conn = None