Skip to content

Commit

Permalink
k8s and vm configs
Browse files Browse the repository at this point in the history
  • Loading branch information
vivian-rook committed Oct 18, 2023
1 parent 7c31b99 commit 4116b89
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
11 changes: 8 additions & 3 deletions quarry/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion quarry/web/killer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
20 changes: 11 additions & 9 deletions quarry/web/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4116b89

Please sign in to comment.