new(all): #156 and node update.

This commit is contained in:
rodrigorodriguez 2023-02-26 06:05:57 -03:00
parent 62a1ed36e2
commit 68de407d63
6 changed files with 51 additions and 37 deletions

View file

@ -1,7 +1,7 @@
dist: focal dist: focal
language: node_js language: node_js
node_js: node_js:
- 19.6.0 - 19.7.0
notifications: notifications:

View file

@ -6,23 +6,25 @@ import { exec } from 'child_process';
import pjson from './package.json' assert { type: 'json' }; import pjson from './package.json' assert { type: 'json' };
// Displays version of Node JS being used at runtime and others attributes. // Displays version of Node JS being used at runtime and others attributes.
console.log(``); console.log(``);
console.log(``); console.log(``);
console.log(` ██████ ███████ ███ ██ ███████ ██████ █████ ██ ██████ ██████ ████████ ███████ ® `); console.log(` █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® `);
console.log(`██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ `); console.log(`██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ `);
console.log(`██ ███ █████ ██ ██ ██ █████ ██████ ███████ ██ ██████ ██ ██ ██ ███████ `); console.log(`██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ `);
console.log(`██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ `); console.log(`██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ `);
console.log(` ██████ ███████ ██ ████ ███████ ██ ██ ██ ██ ██████ ██████ ██████ ██ ███████ 3.0`); console.log(` █████ █████ █ ███ █████ ██ ██ ██ ██ ██████ ████ █████ █ ███ 3.0`);
console.log(`botserver@${pjson.version}, botlib@${pjson.dependencies.botlib}, botbuilder@${pjson.dependencies.botbuilder}, node@${process.version}, ${process.platform}(${process.arch}).`); console.log(` botserver@${pjson.version}, botlib@${pjson.dependencies.botlib}, botbuilder@${pjson.dependencies.botbuilder}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch}`);
var now = () => { var now = () => {
return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC'; return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC';
}; };
var __dirname = process.env.PWD || process.cwd(); var __dirname = process.env.PWD || process.cwd();
try { try {
var run = () => { var run = () => {
import('./dist/src/app.js').then((gb)=> gb.GBServer.run()); import('./dist/src/app.js').then((gb)=> {
console.log(``);
gb.GBServer.run()
});
}; };
var processDist = () => { var processDist = () => {
if (!Fs.existsSync('dist')) { if (!Fs.existsSync('dist')) {

View file

@ -14,7 +14,7 @@
"Dário Vieira <dario.junior3@gmail.com>" "Dário Vieira <dario.junior3@gmail.com>"
], ],
"engines": { "engines": {
"node": "=19.6.0" "node": "=19.7.0"
}, },
"license": "AGPL-3.0", "license": "AGPL-3.0",
"preferGlobal": true, "preferGlobal": true,

View file

@ -57,6 +57,7 @@ import { GBConfigService } from './GBConfigService.js';
import { GBImporter } from './GBImporterService.js'; import { GBImporter } from './GBImporterService.js';
import { TeamsService } from '../../teams.gblib/services/TeamsService.js'; import { TeamsService } from '../../teams.gblib/services/TeamsService.js';
import MicrosoftGraph from '@microsoft/microsoft-graph-client'; import MicrosoftGraph from '@microsoft/microsoft-graph-client';
import { GBLogEx } from './GBLogEx.js';
/** /**
* Deployer service for bots, themes, ai and more. * Deployer service for bots, themes, ai and more.
@ -655,8 +656,8 @@ export class GBDeployer implements IGBDeployer {
break; break;
default: default:
throw GBError.create(`Unhandled package type: ${packageType}.`); throw GBError.create(`Unhandled package type: ${packageType}.`);
} }
} }
/** /**
@ -712,38 +713,45 @@ export class GBDeployer implements IGBDeployer {
*/ */
public async rebuildIndex(instance: IGBInstance, searchSchema: any) { public async rebuildIndex(instance: IGBInstance, searchSchema: any) {
// Prepares search. // Prepares search.
let release;
const search = new AzureSearch(
instance.searchKey,
instance.searchHost,
instance.searchIndex,
instance.searchIndexer
);
const connectionString = GBDeployer.getConnectionStringFromInstance(instance);
const dsName = 'gb';
try { try {
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString); GBLogEx.info(instance.instanceId, `Acquiring rebuildIndex mutex...`);
} catch (err) { release = await GBServer.globals.indexSemaphore.acquire();
GBLog.error(err);
} const search = new AzureSearch(
instance.searchKey,
instance.searchHost,
instance.searchIndex,
instance.searchIndexer
);
const connectionString = GBDeployer.getConnectionStringFromInstance(instance);
const dsName = 'gb';
try {
await search.createDataSource(dsName, dsName, 'GuaribasQuestion', 'azuresql', connectionString);
} catch (err) {
GBLog.error(err);
}
// Removes the index. // Removes the index.
try { try {
await search.createIndex(searchSchema, dsName); await search.createIndex(searchSchema, dsName);
} catch (err) { } catch (err) {
// If it is a 404 there is nothing to delete as it is the first creation. // If it is a 404 there is nothing to delete as it is the first creation.
if (err.code !== 404 && err.code !== 'OperationNotAllowed') { if (err.code !== 404 && err.code !== 'OperationNotAllowed') {
}
}
GBLogEx.info(instance.instanceId, `Acquire rebuildIndex done.`);
await search.rebuildIndex(instance.searchIndexer);
release();
GBLogEx.info(instance.instanceId, `Released rebuildIndex mutex.`);
} catch {
if (release) {
release();
} }
} }
await search.rebuildIndex(instance.searchIndexer);
} }
/** /**

View file

@ -59,4 +59,5 @@ export class RootData {
public debugConversationId: any; // Used to self-message during debug. public debugConversationId: any; // Used to self-message during debug.
public debuggers: any[]; // Client of attached Debugger instances by botId. public debuggers: any[]; // Client of attached Debugger instances by botId.
public chatGPT: any; // ChatGPT API handle (shared Browser). public chatGPT: any; // ChatGPT API handle (shared Browser).
indexSemaphore: any;
} }

View file

@ -56,6 +56,7 @@ import child_process from 'child_process';
import * as winston from 'winston-logs-display'; import * as winston from 'winston-logs-display';
import { RootData } from './RootData.js'; import { RootData } from './RootData.js';
import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js'; import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js';
import { Mutex } from 'async-mutex';
/** /**
* General Bots open-core entry point. * General Bots open-core entry point.
@ -95,6 +96,8 @@ export class GBServer {
GBServer.globals.wwwroot = null; GBServer.globals.wwwroot = null;
GBServer.globals.entryPointDialog = null; GBServer.globals.entryPointDialog = null;
GBServer.globals.debuggers = []; GBServer.globals.debuggers = [];
GBServer.globals.indexSemaphore = new Mutex();
server.use(bodyParser.json()); server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: true })); server.use(bodyParser.urlencoded({ extended: true }));