Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyLaw committed Nov 28, 2019
1 parent b8670c9 commit 6b04384
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
15 changes: 12 additions & 3 deletions BotProject/Templates/CSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics;
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -22,14 +23,23 @@ public static IWebHost BuildWebHost(string[] args) =>
{
var env = hostingContext.HostingEnvironment;
var luisAuthoringRegion = Environment.GetEnvironmentVariable("LUIS_AUTHORING_REGION") ?? "westus";
var luisSettingFiles = Directory.GetFiles($"ComposerDialogs\\generated", "luis.settings.*.json");
config
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
.AddJsonFile($"ComposerDialogs/settings/appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile(luisSettingFiles.Length > 0 ? luisSettingFiles[0] : string.Empty, optional: true, reloadOnChange: true)
.AddJsonFile($"luis.settings.{env.EnvironmentName}.{luisAuthoringRegion}.json", optional: true, reloadOnChange: true)
.AddJsonFile($"luis.settings.{Environment.UserName}.{luisAuthoringRegion}.json", optional: true, reloadOnChange: true);
try
{
foreach (string filePath in Directory.GetFiles($"ComposerDialogs", "generated/luis.settings.*.json"))
{
config.AddJsonFile(filePath, optional: true, reloadOnChange: true);
}
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
if (env.IsDevelopment())
{
Expand All @@ -41,6 +51,5 @@ public static IWebHost BuildWebHost(string[] args) =>
.AddCommandLine(args);
}).UseStartup<Startup>()
.Build();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CSharpBotConnector implements IBotConnector {

private buildProcess = async (dir: string): Promise<number | null> => {
return new Promise((resolve, reject) => {
const startScript = Path.resolve(__dirname, './build_runtime.ps1');
const startScript = Path.resolve(dir, './Scripts/build_runtime.ps1');
console.log(startScript);
const build = spawn(`pwsh ${startScript}`, {
cwd: dir,
Expand Down Expand Up @@ -144,23 +144,20 @@ export class CSharpBotConnector implements IBotConnector {
stdio: ['ignore', 'ignore', 'inherit'],
}
);
console.log(`start runtime at ${this.runtime.pid}`);
this.addListeners(this.runtime, this.stop);
};

connect = async (_: BotEnvironments, __: string) => {
// confirm bot runtime is listening here
try {
const dir = this.getBotPath();
await this.buildProcess(dir);
return Promise.resolve(`${this.endpoint}/api/messages`);
} catch (err) {
throw new Error(err);
}
return Promise.resolve(`${this.endpoint}/api/messages`);
};

sync = async (config: DialogSetting) => {
try {
this.stop();
const dir = this.getBotPath();
await this.buildProcess(dir);
await this.start(dir, config);
} catch (err) {
this.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DefaultEnvironment implements IEnvironment {
public constructor(config: IEnvironmentConfig) {
this.config = config;
this.settingManager = new DefaultSettingManager(this.config.basePath);
console.log(this.config.basePath);
this.botConnector = new CSharpBotConnector(this.config.endpoint);
}

Expand Down

0 comments on commit 6b04384

Please sign in to comment.