mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-11 13:58:58 +00:00
feat(core): Add multi-instance config
This commit is contained in:
@@ -327,6 +327,10 @@ class Config(metaclass=Singleton):
|
|||||||
self.FILE_SERVER_LOCAL_STORAGE_PATH = os.getenv(
|
self.FILE_SERVER_LOCAL_STORAGE_PATH = os.getenv(
|
||||||
"FILE_SERVER_LOCAL_STORAGE_PATH"
|
"FILE_SERVER_LOCAL_STORAGE_PATH"
|
||||||
)
|
)
|
||||||
|
# multi-instance flag
|
||||||
|
self.WEBSERVER_MULTI_INSTANCE = (
|
||||||
|
os.getenv("MULTI_INSTANCE", "False").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def local_db_manager(self) -> "ConnectorManager":
|
def local_db_manager(self) -> "ConnectorManager":
|
||||||
|
@@ -52,7 +52,7 @@ def initialize_components(
|
|||||||
param, system_app, embedding_model_name, embedding_model_path
|
param, system_app, embedding_model_name, embedding_model_path
|
||||||
)
|
)
|
||||||
_initialize_rerank_model(param, system_app, rerank_model_name, rerank_model_path)
|
_initialize_rerank_model(param, system_app, rerank_model_name, rerank_model_path)
|
||||||
_initialize_model_cache(system_app)
|
_initialize_model_cache(system_app, param.port)
|
||||||
_initialize_awel(system_app, param)
|
_initialize_awel(system_app, param)
|
||||||
# Initialize resource manager of agent
|
# Initialize resource manager of agent
|
||||||
_initialize_resource_manager(system_app)
|
_initialize_resource_manager(system_app)
|
||||||
@@ -62,7 +62,7 @@ def initialize_components(
|
|||||||
register_serve_apps(system_app, CFG, param.port)
|
register_serve_apps(system_app, CFG, param.port)
|
||||||
|
|
||||||
|
|
||||||
def _initialize_model_cache(system_app: SystemApp):
|
def _initialize_model_cache(system_app: SystemApp, port: int):
|
||||||
from dbgpt.storage.cache import initialize_cache
|
from dbgpt.storage.cache import initialize_cache
|
||||||
|
|
||||||
if not CFG.MODEL_CACHE_ENABLE:
|
if not CFG.MODEL_CACHE_ENABLE:
|
||||||
@@ -72,6 +72,8 @@ def _initialize_model_cache(system_app: SystemApp):
|
|||||||
storage_type = CFG.MODEL_CACHE_STORAGE_TYPE or "disk"
|
storage_type = CFG.MODEL_CACHE_STORAGE_TYPE or "disk"
|
||||||
max_memory_mb = CFG.MODEL_CACHE_MAX_MEMORY_MB or 256
|
max_memory_mb = CFG.MODEL_CACHE_MAX_MEMORY_MB or 256
|
||||||
persist_dir = CFG.MODEL_CACHE_STORAGE_DISK_DIR or MODEL_DISK_CACHE_DIR
|
persist_dir = CFG.MODEL_CACHE_STORAGE_DISK_DIR or MODEL_DISK_CACHE_DIR
|
||||||
|
if CFG.WEBSERVER_MULTI_INSTANCE:
|
||||||
|
persist_dir = f"{persist_dir}_{port}"
|
||||||
initialize_cache(system_app, storage_type, max_memory_mb, persist_dir)
|
initialize_cache(system_app, storage_type, max_memory_mb, persist_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -94,6 +94,8 @@ def register_serve_apps(system_app: SystemApp, cfg: Config, webserver_port: int)
|
|||||||
local_storage_path = (
|
local_storage_path = (
|
||||||
cfg.FILE_SERVER_LOCAL_STORAGE_PATH or FILE_SERVER_LOCAL_STORAGE_PATH
|
cfg.FILE_SERVER_LOCAL_STORAGE_PATH or FILE_SERVER_LOCAL_STORAGE_PATH
|
||||||
)
|
)
|
||||||
|
if cfg.WEBSERVER_MULTI_INSTANCE:
|
||||||
|
local_storage_path = f"{local_storage_path}_{webserver_port}"
|
||||||
# Set config
|
# Set config
|
||||||
system_app.config.set(
|
system_app.config.set(
|
||||||
f"{FILE_SERVE_CONFIG_KEY_PREFIX}local_storage_path", local_storage_path
|
f"{FILE_SERVE_CONFIG_KEY_PREFIX}local_storage_path", local_storage_path
|
||||||
|
Reference in New Issue
Block a user