mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
22 lines
631 B
TypeScript
22 lines
631 B
TypeScript
import { initSystemConfig } from '.';
|
|
import { createDatasetTrainingMongoWatch } from '@/service/core/dataset/training/utils';
|
|
import { MongoSystemConfigs } from '@fastgpt/service/common/system/config/schema';
|
|
|
|
export const startMongoWatch = async () => {
|
|
reloadConfigWatch();
|
|
createDatasetTrainingMongoWatch();
|
|
};
|
|
|
|
const reloadConfigWatch = () => {
|
|
const changeStream = MongoSystemConfigs.watch();
|
|
|
|
changeStream.on('change', async (change) => {
|
|
try {
|
|
if (change.operationType === 'insert') {
|
|
await initSystemConfig();
|
|
console.log('refresh system config');
|
|
}
|
|
} catch (error) {}
|
|
});
|
|
};
|