new(all): TRUE multicloud.

This commit is contained in:
Rodrigo Rodriguez 2024-08-20 15:26:07 -03:00
parent 3d1624ac23
commit 367e45f5f5
3 changed files with 25 additions and 19 deletions

View file

@ -173,8 +173,9 @@ export class GBMinService {
await CollectionUtil.asyncForEach(
instances,
(async instance => {
if (!GBConfigService.get('STORAGE_NAME')) {
startRouter(GBServer.globals.server, instance.botId);
}
try {
GBLog.info(`Mounting ${instance.botId}...`);
@ -699,8 +700,8 @@ export class GBMinService {
config['domain'] = `http://localhost:${process.env.PORT}/directline/${botId}`;
} else {
const webchatTokenContainer = await this.getWebchatToken(instance);
config['conversationId']= webchatTokenContainer.conversationId,
config['webchatToken'] = webchatTokenContainer.token;
(config['conversationId'] = webchatTokenContainer.conversationId),
(config['webchatToken'] = webchatTokenContainer.token);
}
res.send(JSON.stringify(config));
@ -844,8 +845,7 @@ export class GBMinService {
GBServer.globals.minBoot = min;
GBServer.globals.minBoot.instance.marketplaceId = GBConfigService.get('MARKETPLACE_ID');
GBServer.globals.minBoot.instance.marketplacePassword = GBConfigService.get('MARKETPLACE_SECRET');
}
else{
} else {
url = `/api/messages`;
GBServer.globals.server.post(url, receiver);
}

View file

@ -124,7 +124,7 @@ export class GBServer {
process.on('uncaughtException', (err, p) => {
GBLogEx.error(
0,
`GBEXCEPTION: ${GBUtil.toYAML(JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err))))}`
`GBEXCEPTION: ${GBUtil.toYAML(err)}`
);
});
@ -140,7 +140,7 @@ export class GBServer {
if (!bypass) {
GBLogEx.error(
0,
`GBREJECTION: ${GBUtil.toYAML(JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err))))}`
`GBREJECTION: ${GBUtil.toYAML(err)}`
);
}
});

View file

@ -68,7 +68,6 @@ export class GBUtil {
}
public static async getDirectLineClient(min) {
let config = {
url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`,
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
@ -83,10 +82,17 @@ export class GBUtil {
return await new SwaggerClient(config);
}
public static toYAML(json) {
const doc = new YAML.Document();
doc.contents = json;
return doc.toString();
public static toYAML(data) {
const extractProps = (obj) => {
return Object.getOwnPropertyNames(obj).reduce((acc, key) => {
const value = obj[key];
acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value;
return acc;
}, {});
};
const extractedError = extractProps(data);
return YAML.stringify(extractedError);
}
public static sleep(ms) {