mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-21 03:12:10 +08:00
修改 - 配置文件结构
This commit is contained in:
parent
5fb8b5448a
commit
f70d2a981d
2
.gitignore
vendored
2
.gitignore
vendored
@ -14,7 +14,7 @@ public/*.json
|
||||
McserverConfig.json
|
||||
core/*.json
|
||||
public/common/URL.js
|
||||
|
||||
property.js
|
||||
|
||||
# node
|
||||
node_modules/
|
||||
|
24
app.js
24
app.js
@ -9,17 +9,28 @@ try {
|
||||
//忽略任何版本检测导致的错误
|
||||
}
|
||||
|
||||
const fs = require('fs');
|
||||
const fsex = require('fs-extra');
|
||||
|
||||
//总全局变量
|
||||
global.MCSERVER = {};
|
||||
|
||||
//全局仅限本地配置
|
||||
MCSERVER.localProperty = {};
|
||||
|
||||
const tools = require('./core/tools');
|
||||
|
||||
//生成第一次配置文件
|
||||
const INIT_CONFIG_PATH = './model/init_config/';
|
||||
const PRO_CONFIG = './property.js';
|
||||
if (!fs.existsSync(PRO_CONFIG))
|
||||
tools.mCopyFileSync(INIT_CONFIG_PATH + 'property.js', PRO_CONFIG);
|
||||
|
||||
//加载配置
|
||||
require('./property');
|
||||
|
||||
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
const session = require('express-session');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const bodyParser = require('body-parser');
|
||||
@ -39,7 +50,7 @@ const counter = require('./core/counter');
|
||||
const DataModel = require('./core/DataModel');
|
||||
const ftpServerInterface = require('./ftpd/ftpserver');
|
||||
const tokenManger = require('./helper/TokenManager');
|
||||
const fsex = require('fs-extra');
|
||||
|
||||
|
||||
//控制台颜色
|
||||
const colors = require('colors');
|
||||
@ -187,7 +198,7 @@ process.on("uncaughtException", function (err) {
|
||||
const SERVER_PATH_CORE = './server/server_core/';
|
||||
const CENTEN_LOG_JSON_PATH = './core/info.json';
|
||||
const PUBLIC_URL_PATH = './public/common/URL.js';
|
||||
const INIT_CONFIG_PATH = './model/init_config/'
|
||||
|
||||
try {
|
||||
if (!fs.existsSync(USERS_PATH)) fs.mkdirSync(USERS_PATH);
|
||||
if (!fs.existsSync(SERVER_PATH)) {
|
||||
@ -196,11 +207,10 @@ process.on("uncaughtException", function (err) {
|
||||
|
||||
// 生成不 git 同步的文件
|
||||
if (!fs.existsSync(CENTEN_LOG_JSON_PATH))
|
||||
fsex.copy(INIT_CONFIG_PATH + 'info_reset.json', CENTEN_LOG_JSON_PATH, (err) => {});
|
||||
tools.mCopyFileSync(INIT_CONFIG_PATH + 'info_reset.json', CENTEN_LOG_JSON_PATH);
|
||||
if (!fs.existsSync(PUBLIC_URL_PATH))
|
||||
fsex.copy(INIT_CONFIG_PATH + 'INIT_URL.js', PUBLIC_URL_PATH, (err) => {});
|
||||
if (!fs.existsSync(PUBLIC_URL_PATH))
|
||||
fsex.copy(INIT_CONFIG_PATH + 'property.js', './property.js', (err) => {});
|
||||
tools.mCopyFileSync(INIT_CONFIG_PATH + 'INIT_URL.js', PUBLIC_URL_PATH);
|
||||
|
||||
} catch (err) {
|
||||
MCSERVER.error('初始化文件环境失败,建议重启,请检查以下报错:', err);
|
||||
}
|
||||
|
@ -42,4 +42,15 @@ module.exports.autoLoadModule = (proPath, minePath, callback) => {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports.mCopyFileSync = (oldpath, newpath) => {
|
||||
let resetData = fs.readFileSync(oldpath, {
|
||||
encoding: 'UTF-8'
|
||||
});
|
||||
fs.writeFileSync(newpath, resetData, {
|
||||
encoding: 'UTF-8'
|
||||
});
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue
Block a user