WIP: Attempt to fix bug with Azure platform
This commit is contained in:
parent
566899d369
commit
ef80578163
6 changed files with 34 additions and 16 deletions
|
@ -39,7 +39,7 @@
|
|||
const crypto = require('crypto');
|
||||
const rimraf = require('rimraf');
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBMinInstance, IGBDialog, GBLog } from 'botlib';
|
||||
import urlJoin = require('url-join');
|
||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
|
@ -80,6 +80,7 @@ export class AdminDialog extends IGBDialog {
|
|||
let folderName = text.split(' ')[2];
|
||||
|
||||
let localFolder = Path.join('work', Path.basename(folderName));
|
||||
GBLog.warn(`${GBConfigService.get('CLOUD_USERNAME')} must be authorized on SharePoint related site`);
|
||||
await s.downloadFolder(localFolder, siteName, folderName,
|
||||
GBConfigService.get('CLOUD_USERNAME'), GBConfigService.get('CLOUD_PASSWORD'))
|
||||
await deployer.deployPackage(min, localFolder);
|
||||
|
@ -152,6 +153,12 @@ export class AdminDialog extends IGBDialog {
|
|||
} else if (cmdName === 'deployPackage') {
|
||||
await AdminDialog.deployPackageCommand(min, text, deployer);
|
||||
|
||||
return await step.replaceDialog('/admin', { firstRun: false });
|
||||
} else if (cmdName === 'dp') {
|
||||
let BOT_NAME = text;
|
||||
let address = `https://pragmatismo.sharepoint.com/sites/bots /Shared%20Documents/Rascunho/${BOT_NAME}/${BOT_NAME}.gbai/${BOT_NAME}.gbkb`;
|
||||
await AdminDialog.deployPackageCommand(min, address, deployer);
|
||||
|
||||
return await step.replaceDialog('/admin', { firstRun: false });
|
||||
} else if (cmdName === 'redeployPackage') {
|
||||
await step.context.sendActivity('The package is being *unloaded*...');
|
||||
|
|
|
@ -126,6 +126,9 @@ export class GBConfigService {
|
|||
case 'REVERSE_PROXY':
|
||||
value = undefined;
|
||||
break;
|
||||
case 'STORAGE_ACQUIRE_TIMEOUT':
|
||||
value = 40000;
|
||||
break;
|
||||
default:
|
||||
GBLog.warn(`Invalid key on .env file: '${key}'`);
|
||||
break;
|
||||
|
|
|
@ -82,7 +82,7 @@ export class GBConversationalService implements IGBConversationalService {
|
|||
msg.type = 'event';
|
||||
msg.name = name;
|
||||
|
||||
return step.context.sendActivity(msg);
|
||||
return await step.context.sendActivity(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ export class GBCoreService implements IGBCoreService {
|
|||
|
||||
const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true';
|
||||
|
||||
const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT'));
|
||||
this.sequelize = new Sequelize({
|
||||
host: host,
|
||||
database: database,
|
||||
|
@ -149,7 +150,7 @@ export class GBCoreService implements IGBCoreService {
|
|||
min: 8,
|
||||
idle: 40000,
|
||||
evict: 40000,
|
||||
acquire: 40000
|
||||
acquire: acquire
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -291,8 +292,8 @@ STORAGE_SYNC=true
|
|||
let instance = await GuaribasInstance.findOne(options);
|
||||
// tslint:disable-next-line:prefer-object-spread
|
||||
instance = Object.assign(instance, fullInstance);
|
||||
|
||||
return await instance.save();
|
||||
let ret = await instance.save();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -207,6 +207,7 @@ export class GBDeployer {
|
|||
instance.storageName = bootInstance.storageName;
|
||||
instance.storageUsername = bootInstance.storageUsername;
|
||||
instance.storagePassword = bootInstance.storagePassword;
|
||||
instance.webchatKey = bootInstance.webchatKey;
|
||||
|
||||
instance = await service.internalDeployBot(
|
||||
instance,
|
||||
|
|
|
@ -54,35 +54,41 @@ export class GBImporter {
|
|||
}
|
||||
|
||||
public async importIfNotExistsBotPackage(botId: string, packageName: string, localPath: string) {
|
||||
const packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
const settingsJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
|
||||
if (botId === undefined) {
|
||||
botId = packageJson.botId;
|
||||
botId = settingsJson.botId;
|
||||
}
|
||||
if (botId === undefined) {
|
||||
botId = GBConfigService.get('BOT_ID');
|
||||
}
|
||||
const instance = await this.core.loadInstance(botId);
|
||||
|
||||
return await this.createOrUpdateInstanceInternal(instance, botId, localPath, packageJson);
|
||||
|
||||
if (instance.botId === undefined || instance.botId === null) {
|
||||
console.log("••• Atenção botId é nulo ou undefined");
|
||||
}
|
||||
return await this.createOrUpdateInstanceInternal(instance, botId, localPath, settingsJson);
|
||||
}
|
||||
|
||||
private async createOrUpdateInstanceInternal(instance: IGBInstance,
|
||||
botId: string, localPath: string, packageJson: any) {
|
||||
const settings = JSON.parse(fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
|
||||
botId: string, localPath: string, settingsJson: any) {
|
||||
let packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
const servicesJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'services.json'), 'utf8'));
|
||||
|
||||
packageJson = { ...GBServer.globals.bootInstance, ...packageJson, ...settings, ...servicesJson };
|
||||
let fullSettingsJson = { ...GBServer.globals.bootInstance, ...packageJson, ...settingsJson, ...servicesJson };
|
||||
|
||||
if (botId !== undefined) {
|
||||
packageJson.botId = botId;
|
||||
fullSettingsJson.botId = botId;
|
||||
}
|
||||
|
||||
if (instance !== null) {
|
||||
instance = { ...instance, ...packageJson, ...settings, ...servicesJson };
|
||||
instance = { ...instance, ...fullSettingsJson };
|
||||
|
||||
return this.core.saveInstance(instance);
|
||||
if (instance.botId === undefined || instance.botId === null) {
|
||||
console.log("••• Atenção botId é nulo ou undefined");
|
||||
}
|
||||
return await this.core.saveInstance(instance);
|
||||
} else {
|
||||
return await GuaribasInstance.create(packageJson);
|
||||
return await GuaribasInstance.create(fullSettingsJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue