修改了conf.json的读取路径

This commit is contained in:
lik
2026-09-13 11:40:42 +08:00
parent 41bf2ce638
commit cd284e3459
7 changed files with 37 additions and 22 deletions
+18
View File
@@ -0,0 +1,18 @@
import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// 优先读取系统级配置,其次读取项目目录下的配置
const SYSTEM_CONF = '/etc/ehason/conf.json';
const LOCAL_CONF = path.join(__dirname, 'conf.json');
function loadConfig() {
const file = existsSync(SYSTEM_CONF) ? SYSTEM_CONF : LOCAL_CONF;
return JSON.parse(readFileSync(file, 'utf-8'));
}
const config = loadConfig();
export default config;