修改初始化目录结构

This commit is contained in:
suwings 2017-11-18 15:13:01 +08:00
parent 8e5ebead14
commit 7a4c748289
2 changed files with 25 additions and 20 deletions

3
.gitignore vendored
View File

@ -6,4 +6,5 @@ testServer/
users/*.json users/*.json
server/*.json server/*.json
public/*.json public/*.json
McserverConfig.json McserverConfig.json
core/*.json

42
app.js
View File

@ -155,26 +155,30 @@ process.on("uncaughtException", function (err) {
MCSERVER.error('UncaughtException 机制错误报告:', err); MCSERVER.error('UncaughtException 机制错误报告:', err);
}); });
//初始化环境 //初始化目录结构环境
const USERS_PATH = './users/'; (function initializationRun() {
const SERVER_PATH = './server/'; const USERS_PATH = './users/';
const SERVER_PATH_CORE = './server/server_core/'; const SERVER_PATH = './server/';
try { const SERVER_PATH_CORE = './server/server_core/';
if (!fs.existsSync(USERS_PATH)) fs.mkdirSync(USERS_PATH); const CENTEN_LOG_JSON_PATH = './core/info.json';
if (!fs.existsSync(SERVER_PATH)) { try {
fs.mkdirSync(SERVER_PATH); if (!fs.existsSync(USERS_PATH)) fs.mkdirSync(USERS_PATH);
fs.mkdirSync(SERVER_PATH_CORE); if (!fs.existsSync(SERVER_PATH)) {
// fs.renameSync('./core/info_reset.json','./core/info.json'); fs.mkdirSync(SERVER_PATH);
let resetData = fs.readFileSync('./core/info_reset.json', { fs.mkdirSync(SERVER_PATH_CORE);
encoding: 'UTF-8' }
}); if (!fs.existsSync(CENTEN_LOG_JSON_PATH)) {
fs.writeFileSync('./core/info.json', resetData, { let resetData = fs.readFileSync('./core/info_reset.json', {
encoding: 'UTF-8' encoding: 'UTF-8'
}); });
fs.writeFileSync('./core/info.json', resetData, {
encoding: 'UTF-8'
});
}
} catch (err) {
MCSERVER.error('初始化文件环境失败,建议重启,请检查以下报错:', err);
} }
} catch (err) { })();
MCSERVER.error('初始化失败,建议重启,如果依然如此,请检查以下报错:',err);
}
function serverAppListen() { function serverAppListen() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {