From 7a55132e42c8964bbc4efc95067844f7d7bf05f0 Mon Sep 17 00:00:00 2001 From: Andreas <21068727+ndrsfel@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:59:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20feat:=20optional=20librechat.yam?= =?UTF-8?q?l=20path=20via=20environment=20variable=20(#1858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: afel --- .env.example | 6 ++++++ api/server/services/Config/loadCustomConfig.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 6ecd2d8d0d..ab9b57756a 100644 --- a/.env.example +++ b/.env.example @@ -40,6 +40,12 @@ DEBUG_CONSOLE=false # UID=1000 # GID=1000 +#===============# +# Configuration # +#===============# + +# CONFIG_PATH="/alternative/path/to/librechat.yaml" + #===================================================# # Endpoints # #===================================================# diff --git a/api/server/services/Config/loadCustomConfig.js b/api/server/services/Config/loadCustomConfig.js index eecf8eff82..dc29e3329c 100644 --- a/api/server/services/Config/loadCustomConfig.js +++ b/api/server/services/Config/loadCustomConfig.js @@ -5,7 +5,7 @@ const { getLogStores } = require('~/cache'); const { logger } = require('~/config'); const projectRoot = path.resolve(__dirname, '..', '..', '..', '..'); -const configPath = path.resolve(projectRoot, 'librechat.yaml'); +const defaultConfigPath = path.resolve(projectRoot, 'librechat.yaml'); let i = 0; @@ -16,6 +16,9 @@ let i = 0; * @returns {Promise} A promise that resolves to null or the custom config object. * */ async function loadCustomConfig() { + // Use CONFIG_PATH if set, otherwise fallback to defaultConfigPath + const configPath = process.env.CONFIG_PATH || defaultConfigPath; + const customConfig = loadYaml(configPath); if (!customConfig) { i === 0 &&