代码拉取完成,页面将自动刷新
同步操作将从 AvenirTech 未来科技/AvenirSQL 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// AvenirSQL
const Socket = require('./tcp/socket');
const Core = require('./database/Core');
const User = require('./database/User');
const os = require('os');
const fs = require('fs');
const INI = require('ini');
const path = require('path');
const Logger = require('avenir-log');
const constants = require('./tools/constants');
const Conn = require('./database/Conn');
const Nodis = require('./database/Nodis');
const _ = require('lodash');
const nthFile = require('nth-file');
const Lock = require('./database/Lock');
const SQL = require('./database/Sql');
const Trans = require('./database/Trans');
const Trace = require('./database/Trace');
const libcu = require('libcu');
async function start() {
let socket = new Socket();
let sql = new SQL();
let core = new Core();
let user = new User();
let file = await giveFileName();
//如果没有ini文件就自创一个
if (!fs.existsSync(file)) {
defaultIni();
}
let ini = await readIni(file);
let log = new Logger(ini.log.logName, ini.log.logPath);
let conn = new Conn();
//不希望没事就写日志 上生产了再说
ini.db.debug || log.noDebug();
global.log = log;
global.socket = socket;
//为了防止名称冲突
global.define = {
fileName: file,
}
global.ini = ini;
global.db = core; //core 名称冲突
global.sql = sql;
global.user = user;
global.conn = conn;
//nodis一定要创建在ini的后面 因为用到了ini的定义
let nodis = new Nodis();
global.nodis = nodis;
let lock = new Lock();
global._ = _;
global.lock = lock;
let trans = new Trans();
global.trans = trans;
let trace = new Trace();
global.trace = trace;
global.nthFile = nthFile;
global.constants = constants;
await socket.init(ini.main.ip, ini.main.port);//启动sock
dbInit();
}
async function main() {
await start();
}
async function giveFileName() {
let type = os.platform();
let fileName;
if (type == "darwin" && constants.ifSingle) {
fileName = "/Users/hideyoshi/Desktop/codes/avenir-db/run.ini";
}
else if (type == "win32" && constants.ifSingle) {
fileName = "F:/avenir-db/run.ini";
}
else {
fileName = "./run.ini"
}
return fileName;
}
async function readIni(fileName) {
let file = fs.readFileSync(fileName);
var info = INI.parse(file.toString());
return info;
}
//初始化数据库配置信息
function dbInit() {
let fileName = ini.name.rootSet;
fileName = path.join(ini.main.path, fileName);
if (!fs.existsSync(ini.main.path)) {
fs.mkdirSync(ini.main.path, { recursive: true });
}
if (!fs.existsSync(fileName)) {
fs.writeFileSync(fileName, '{}'); //默认写一个空的配置
}
}
function defaultIni() {
let ini = {
main: {
ip: '127.0.0.1',
port: '44944',
path: './db',
ifConsoleLog: true
},
db: {
keepAlive: false,
debug: false,
timeOut: '10000',
maxColoums: '100',
maxSqlLength: '200',
user: 'User',
cacheInvalid: '200',
clearCache: '500',
updateCache: '1',
lockTimeOut: '3',
lockTryTime: '10',
releaseLockTime: '10',
checkLockTime: '10'
},
name: {
table: '.table',
index: '.bpx',
hash: '.hash',
rootSet: 'AvenirSQL.json',
dbSet: '.json'
},
curl: {}
}
fs.writeFileSync('./run.ini', INI.stringify(ini));
}
main();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。