Skip to content

Commit

Permalink
fix(all): Bug fix in startup on a blank environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Oct 26, 2020
1 parent 3511a9b commit 7a2232e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/boot.gbot/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"searchScore": ".45",
"nlpScore": ".80",
"nlpVsSearch": ".4",
"state":"active",
"autoPackageSync": "gbdialog, gbot, gbtheme"
}
6 changes: 5 additions & 1 deletion packages/core.gbapp/services/GBImporterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 16 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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.
Expand Down

0 comments on commit 7a2232e

Please sign in to comment.