Skip to content

Commit

Permalink
feat(core): Add multi-instance config
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Aug 19, 2024
1 parent 7c241b6 commit 3d1d275
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions dbgpt/_private/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ def __init__(self) -> None:
self.FILE_SERVER_LOCAL_STORAGE_PATH = os.getenv(
"FILE_SERVER_LOCAL_STORAGE_PATH"
)
# multi-instance flag
self.WEBSERVER_MULTI_INSTANCE = (
os.getenv("MULTI_INSTANCE", "False").lower() == "true"
)

@property
def local_db_manager(self) -> "ConnectorManager":
Expand Down
6 changes: 4 additions & 2 deletions dbgpt/app/component_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def initialize_components(
param, system_app, embedding_model_name, embedding_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 resource manager of agent
_initialize_resource_manager(system_app)
Expand All @@ -62,7 +62,7 @@ def initialize_components(
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

if not CFG.MODEL_CACHE_ENABLE:
Expand All @@ -72,6 +72,8 @@ def _initialize_model_cache(system_app: SystemApp):
storage_type = CFG.MODEL_CACHE_STORAGE_TYPE or "disk"
max_memory_mb = CFG.MODEL_CACHE_MAX_MEMORY_MB or 256
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)


Expand Down
2 changes: 2 additions & 0 deletions dbgpt/app/initialization/serve_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def register_serve_apps(system_app: SystemApp, cfg: Config, webserver_port: int)
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
system_app.config.set(
f"{FILE_SERVE_CONFIG_KEY_PREFIX}local_storage_path", local_storage_path
Expand Down

0 comments on commit 3d1d275

Please sign in to comment.