修复初始化环境变量

This commit is contained in:
whyour
2022-07-18 14:16:49 +08:00
parent 027c3f584c
commit 999b5d325f
2 changed files with 14 additions and 13 deletions
+13 -3
View File
@@ -1,10 +1,8 @@
import 'reflect-metadata'; // We need this in order to use @Decorators
import config from './config';
import express from 'express';
import Logger from './loaders/logger';
import path from 'path';
async function startServer() {
const app = express();
@@ -29,4 +27,16 @@ async function startServer() {
await require('./loaders/server').default({ server });
}
function initEnv() {
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// 声明QL_DIR环境变量
let qlHomePath = path.join(__dirname, '../../');
// 生产环境
if (qlHomePath.endsWith('/static/')) {
qlHomePath = path.join(qlHomePath, '../');
}
process.env.QL_DIR = qlHomePath;
}
initEnv();
startServer();