new(all): TRUE multicloud.
This commit is contained in:
parent
3d1624ac23
commit
367e45f5f5
3 changed files with 25 additions and 19 deletions
|
@ -173,8 +173,9 @@ export class GBMinService {
|
||||||
await CollectionUtil.asyncForEach(
|
await CollectionUtil.asyncForEach(
|
||||||
instances,
|
instances,
|
||||||
(async instance => {
|
(async instance => {
|
||||||
|
if (!GBConfigService.get('STORAGE_NAME')) {
|
||||||
startRouter(GBServer.globals.server, instance.botId);
|
startRouter(GBServer.globals.server, instance.botId);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GBLog.info(`Mounting ${instance.botId}...`);
|
GBLog.info(`Mounting ${instance.botId}...`);
|
||||||
|
@ -699,8 +700,8 @@ export class GBMinService {
|
||||||
config['domain'] = `http://localhost:${process.env.PORT}/directline/${botId}`;
|
config['domain'] = `http://localhost:${process.env.PORT}/directline/${botId}`;
|
||||||
} else {
|
} else {
|
||||||
const webchatTokenContainer = await this.getWebchatToken(instance);
|
const webchatTokenContainer = await this.getWebchatToken(instance);
|
||||||
config['conversationId']= webchatTokenContainer.conversationId,
|
(config['conversationId'] = webchatTokenContainer.conversationId),
|
||||||
config['webchatToken'] = webchatTokenContainer.token;
|
(config['webchatToken'] = webchatTokenContainer.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send(JSON.stringify(config));
|
res.send(JSON.stringify(config));
|
||||||
|
@ -844,8 +845,7 @@ export class GBMinService {
|
||||||
GBServer.globals.minBoot = min;
|
GBServer.globals.minBoot = min;
|
||||||
GBServer.globals.minBoot.instance.marketplaceId = GBConfigService.get('MARKETPLACE_ID');
|
GBServer.globals.minBoot.instance.marketplaceId = GBConfigService.get('MARKETPLACE_ID');
|
||||||
GBServer.globals.minBoot.instance.marketplacePassword = GBConfigService.get('MARKETPLACE_SECRET');
|
GBServer.globals.minBoot.instance.marketplacePassword = GBConfigService.get('MARKETPLACE_SECRET');
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
url = `/api/messages`;
|
url = `/api/messages`;
|
||||||
GBServer.globals.server.post(url, receiver);
|
GBServer.globals.server.post(url, receiver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ export class GBServer {
|
||||||
process.on('uncaughtException', (err, p) => {
|
process.on('uncaughtException', (err, p) => {
|
||||||
GBLogEx.error(
|
GBLogEx.error(
|
||||||
0,
|
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) {
|
if (!bypass) {
|
||||||
GBLogEx.error(
|
GBLogEx.error(
|
||||||
0,
|
0,
|
||||||
`GBREJECTION: ${GBUtil.toYAML(JSON.parse(JSON.stringify(err, Object.getOwnPropertyNames(err))))}`
|
`GBREJECTION: ${GBUtil.toYAML(err)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
16
src/util.ts
16
src/util.ts
|
@ -68,7 +68,6 @@ export class GBUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getDirectLineClient(min) {
|
public static async getDirectLineClient(min) {
|
||||||
|
|
||||||
let config = {
|
let config = {
|
||||||
url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`,
|
url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`,
|
||||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||||
|
@ -83,10 +82,17 @@ export class GBUtil {
|
||||||
return await new SwaggerClient(config);
|
return await new SwaggerClient(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static toYAML(json) {
|
public static toYAML(data) {
|
||||||
const doc = new YAML.Document();
|
const extractProps = (obj) => {
|
||||||
doc.contents = json;
|
return Object.getOwnPropertyNames(obj).reduce((acc, key) => {
|
||||||
return doc.toString();
|
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) {
|
public static sleep(ms) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue