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...`);
|
GBLog.info(`Deploying Bot Storage...`);
|
||||||
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
|
const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`;
|
||||||
const administratorPassword = GBAdminService.getRndPassword();
|
const administratorPassword = GBAdminService.getRndPassword();
|
||||||
const storageServer = `${name.toLowerCase()}-storage-server`;
|
const storageServer = `${name.toLowerCase()}-storage-server2`;
|
||||||
const storageName = `${name}-storage`;
|
const storageName = `${name}-storage`;
|
||||||
await this.createStorageServer(name, storageServer, administratorLogin,
|
await this.createStorageServer(name, storageServer, administratorLogin,
|
||||||
administratorPassword, storageServer, instance.cloudLocation
|
administratorPassword, storageServer, instance.cloudLocation
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
"searchScore": ".45",
|
"searchScore": ".45",
|
||||||
"nlpScore": ".80",
|
"nlpScore": ".80",
|
||||||
"nlpVsSearch": ".4",
|
"nlpVsSearch": ".4",
|
||||||
|
"state":"active",
|
||||||
"autoPackageSync": "gbdialog, gbot, gbtheme"
|
"autoPackageSync": "gbdialog, gbot, gbtheme"
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ export class GBImporter {
|
||||||
this.core = core;
|
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'));
|
const settingsJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
|
||||||
if (botId === undefined) {
|
if (botId === undefined) {
|
||||||
botId = settingsJson.botId;
|
botId = settingsJson.botId;
|
||||||
|
@ -86,6 +87,9 @@ export class GBImporter {
|
||||||
if (instance != null && instance.botId === null) {
|
if (instance != null && instance.botId === null) {
|
||||||
console.log(`Null BotId after load instance with botId: ${botId}.`);
|
console.log(`Null BotId after load instance with botId: ${botId}.`);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
instance = additionalInstance;
|
||||||
|
}
|
||||||
|
|
||||||
return await this.createOrUpdateInstanceInternal(instance, botId, localPath, settingsJson);
|
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();
|
await core.initStorage();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.verbose(`Error initializing storage: ${error}`);
|
GBLog.verbose(`Error initializing storage: ${error}`);
|
||||||
|
GBServer.globals.bootInstance =
|
||||||
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
|
await core.createBootInstance(core, azureDeployer, GBServer.globals.publicAddress);
|
||||||
await core.initStorage();
|
await core.initStorage();
|
||||||
}
|
}
|
||||||
|
@ -150,13 +151,24 @@ export class GBServer {
|
||||||
await core.checkStorage(azureDeployer);
|
await core.checkStorage(azureDeployer);
|
||||||
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
|
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
|
||||||
|
|
||||||
// Loads boot bot and other instances.
|
GBLog.info(`Publishing instances...`);
|
||||||
|
|
||||||
let instances: IGBInstance[] = await core.loadAllInstances(
|
let instances: IGBInstance[] = await core.loadAllInstances(
|
||||||
core,
|
core,
|
||||||
azureDeployer,
|
azureDeployer,
|
||||||
GBServer.globals.publicAddress
|
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];
|
GBServer.globals.bootInstance = instances[0];
|
||||||
|
|
||||||
// Builds minimal service infrastructure.
|
// Builds minimal service infrastructure.
|
||||||
|
|
Loading…
Add table
Reference in a new issue