1 Star 0 Fork 10

搁浅/AvenirMQ

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
AvenirMQ.js 3.06 KB
一键复制 编辑 原始数据 按行查看 历史
const Core = require('./core/Core');
const os = require('os');
const fs = require('fs');
const ini = require('ini');
const Logger = require('avenir-log');
async function init() {
let file = await giveFileName();
let ini = await readIni(file);
let log = new Logger('main', './log');
log.noDebug();
global.log = log;
global.ini = ini;
let mq = new Core();
bless();
await mq.init("127.0.0.1", ini.main.port);//启动sock
}
async function main() {
await init();
}
async function giveFileName() {
let type = os.platform();
let fileName;
if (type == "darwin") {
fileName = "/Users/hideyoshi/Desktop/codes/AvenirMQ/run.ini";
}
else if (type == "win32") {
fileName = "F:/AvenirMQ/run.ini";
}
else {
fileName = "./run.ini"
}
return fileName;
}
async function readIni(fileName) {
if(!fs.existsSync(fileName)) {
defalutIni(fileName);
}
let file = fs.readFileSync(fileName);
try {
var Info = ini.parse(file.toString());
return Info;
} catch(error) {
return defalutIni(fileName);
}
}
function bless() {
console.log(`
┌─┐ ┌─┐
┌──┘ ┴───────┘ ┴──┐
│ │
│ ─── │
│ ─┬┘ └┬─ │
│ │
│ ─┴─ │
│ │
└───┐ ┌───┘
│ │
│ │
│ │
│ └──────────────┐
│ │
│ ├─┐
│ ┌─┘
│ │
└─┐ ┐ ┌───────┬──┐ ┌──┘
│ ─┤ ─┤ │ ─┤ ─┤
└──┴──┘ └──┴──┘
神兽保佑
代码无BUG!`);
console.log(`
_______ __ __ _______ __ _ ___ ______ __ __ _______
| _ || | | || || | | || | | _ | | |_| || |
| |_| || |_| || ___|| |_| || | | | || | || _ |
| || || |___ | || | | |_||_ | || | | |
| || || ___|| _ || | | __ || || |_| |
| _ | | | | |___ | | | || | | | | || ||_|| || |
|__| |__| |___| |_______||_| |__||___| |___| |_||_| |_||____||_|`);
}
function defalutIni(fileName) {
const data = {
main: { ip: '127.0.0.1', port: '52013' },
mq: {
userFileName: './user.json',
ifConsoleLog: true,
timeOut: '10',
keepAlive: true,
MQTimeOut: '3',
MQResend: '2',
retryTime: '5',
loopTime: '10',
connClearTime: '20',
signClearTime: '20',
autoClear:'120',
}
}
fs.writeFileSync(fileName,ini.stringify(data));
return data;
}
main();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/nankeyang/AvenirMQ.git
git@gitee.com:nankeyang/AvenirMQ.git
nankeyang
AvenirMQ
AvenirMQ
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385