dev
This commit is contained in:
28
domain-api/app/services/runtime_settings_service.py
Normal file
28
domain-api/app/services/runtime_settings_service.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.files import read_runtime_json, write_runtime_json
|
||||
|
||||
|
||||
DEFAULT_RUNTIME_SETTINGS = {
|
||||
"worker_mode": settings.worker_mode,
|
||||
"worker_service_name": settings.worker_service_name,
|
||||
"api_service_name": settings.api_service_name,
|
||||
}
|
||||
|
||||
|
||||
def get_runtime_settings() -> dict:
|
||||
stored = read_runtime_json("runtime_settings.json", default={})
|
||||
result = dict(DEFAULT_RUNTIME_SETTINGS)
|
||||
result.update(stored or {})
|
||||
return result
|
||||
|
||||
|
||||
def update_runtime_settings(payload: dict) -> dict:
|
||||
current = get_runtime_settings()
|
||||
merged = dict(current)
|
||||
for key in DEFAULT_RUNTIME_SETTINGS:
|
||||
if key in payload and payload[key] is not None:
|
||||
merged[key] = payload[key]
|
||||
write_runtime_json("runtime_settings.json", merged)
|
||||
return merged
|
||||
Reference in New Issue
Block a user