fix(all): Bug fix in startup on a blank environment.

This commit is contained in:
Rodrigo Rodriguez 2020-10-26 20:18:38 -03:00
parent 3511a9bbd0
commit 7a2232efe4
4 changed files with 23 additions and 6 deletions

View file

@ -388,7 +388,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
GBLog.info(`Deploying Bot Storage...`);
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
const administratorPassword = GBAdminService.getRndPassword();
const storageServer = `${name.toLowerCase()}-storage-server`;
const storageServer = `${name.toLowerCase()}-storage-server2`;
const storageName = `${name}-storage`;
await this.createStorageServer(name, storageServer, administratorLogin,
administratorPassword, storageServer, instance.cloudLocation

View file

@ -3,5 +3,6 @@
"searchScore": ".45",
"nlpScore": ".80",
"nlpVsSearch": ".4",
"state":"active",
"autoPackageSync": "gbdialog, gbot, gbtheme"
}

View file

@ -53,7 +53,8 @@ export class GBImporter {
this.core = core;
}
public async importIfNotExistsBotPackage(botId: string, packageName: string, localPath: string) {
public async importIfNotExistsBotPackage(botId: string,
packageName: string, localPath: string, additionalInstance: IGBInstance = null) {
const settingsJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
if (botId === undefined) {
botId = settingsJson.botId;
@ -86,6 +87,9 @@ export class GBImporter {
if (instance != null && instance.botId === null) {
console.log(`Null BotId after load instance with botId: ${botId}.`);
}
else{
instance = additionalInstance;
}
return await this.createOrUpdateInstanceInternal(instance, botId, localPath, settingsJson);
}

View file

@ -137,7 +137,8 @@ export class GBServer {
await core.initStorage();
} catch (error) {
GBLog.verbose(`Error initializing storage: ${error}`);
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
GBServer.globals.bootInstance =
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
await core.initStorage();
}
@ -149,14 +150,25 @@ export class GBServer {
GBServer.globals.sysPackages = await core.loadSysPackages(core);
await core.checkStorage(azureDeployer);
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
// Loads boot bot and other instances.
GBLog.info(`Publishing instances...`);
let instances: IGBInstance[] = await core.loadAllInstances(
core,
azureDeployer,
GBServer.globals.publicAddress
);
if (instances.length === 0) {
const instance = await importer.importIfNotExistsBotPackage(
GBConfigService.get('BOT_ID'),
'boot.gbot',
'packages/boot.gbot',
GBServer.globals.bootInstance
);
await deployer.deployBotFull(instance, GBServer.globals.publicAddress);
instances.push(instance);
}
GBServer.globals.bootInstance = instances[0];
// Builds minimal service infrastructure.