fix(all): Bug fix in startup on a blank environment.
This commit is contained in:
parent
3511a9bbd0
commit
7a2232efe4
4 changed files with 23 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
"searchScore": ".45",
|
||||
"nlpScore": ".80",
|
||||
"nlpVsSearch": ".4",
|
||||
"state":"active",
|
||||
"autoPackageSync": "gbdialog, gbot, gbtheme"
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
16
src/app.ts
16
src/app.ts
|
@ -137,6 +137,7 @@ export class GBServer {
|
|||
await core.initStorage();
|
||||
} catch (error) {
|
||||
GBLog.verbose(`Error initializing storage: ${error}`);
|
||||
GBServer.globals.bootInstance =
|
||||
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
|
||||
await core.initStorage();
|
||||
}
|
||||
|
@ -150,13 +151,24 @@ export class GBServer {
|
|||
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue