-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
43 lines (38 loc) · 1.35 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Directline.Extensions;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace Directline
{
public class Program
{
public static void Main(string[] args)
{
var isService = !Debugger.IsAttached && args.Contains("--service");
if (isService)
{
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
var pathToContentRoot = Path.GetDirectoryName(pathToExe);
Directory.SetCurrentDirectory(pathToContentRoot);
}
var builder = CreateWebHostBuilder(args.Where(arg => arg != "--service").ToArray());
var host = builder.Build();
if(isService) {
host.RunAsCustomService();
} else {
host.Run();
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging)=> {
logging.AddConsole();
})
.UseStartup<Startup>()
.ConfigureLogging(options=> { options.AddConsole(); });
}
}