* lock

* perf: init data

* perf: vision model url

* fix: chat index
This commit is contained in:
Archer
2024-07-17 00:16:57 +08:00
committed by GitHub
parent fc96bb99cc
commit 36f8755d09
26 changed files with 693 additions and 905 deletions

View File

@@ -64,10 +64,13 @@ export const getMongoModel = <T>(name: string, schema: mongoose.Schema) => {
addCommonMiddleware(schema);
const model = connectionMongo.model<T>(name, schema);
try {
model.syncIndexes();
} catch (error) {
addLog.error('Create index error', error);
if (process.env.SYNC_INDEX !== '0') {
try {
model.syncIndexes({ background: true });
} catch (error) {
addLog.error('Create index error', error);
}
}
return model;

View File

@@ -1,3 +1,4 @@
import { exit } from 'process';
import { addLog } from '../system/log';
import { connectionMongo } from './index';
import type { Mongoose } from 'mongoose';
@@ -56,9 +57,13 @@ export async function connectMongo({
}
try {
afterHook && (await afterHook());
if (!global.systemInited) {
global.systemInited = true;
afterHook && (await afterHook());
}
} catch (error) {
addLog.error('mongo connect after hook error', error);
addLog.error('Mongo connect after hook error', error);
exit(1);
}
return connectionMongo;