mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复初始化环境变量
This commit is contained in:
parent
027c3f584c
commit
999b5d325f
16
back/app.ts
16
back/app.ts
|
@ -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();
|
||||
|
|
|
@ -2,19 +2,10 @@ import dotenv from 'dotenv';
|
|||
import path from 'path';
|
||||
import { createRandomString } from './util';
|
||||
|
||||
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;
|
||||
|
||||
const lastVersionFile = `http://qn.whyour.cn/version.ts?v=${Date.now()}`;
|
||||
|
||||
const envFound = dotenv.config();
|
||||
const rootPath = qlHomePath;
|
||||
const rootPath = process.env.QL_DIR as string;
|
||||
const dataPath = path.join(rootPath, 'data/');
|
||||
const samplePath = path.join(rootPath, 'sample/');
|
||||
const configPath = path.join(dataPath, 'config/');
|
||||
|
|
Loading…
Reference in New Issue
Block a user