-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (42 loc) · 1.43 KB
/
Program.cs
File metadata and controls
45 lines (42 loc) · 1.43 KB
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
44
45
using System;
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using WindowsWebServiceManager;
using WindowsWebServiceManager.Cli;
/// <summary>
/// Entry point for Windows Web Service Manager CLI.
/// Mirrors the DI / Hosting pattern used by sibling projects (WindowsServiceManager, etc.).
/// </summary>
internal static class Program
{
private static async System.Threading.Tasks.Task<int> Main(string[] args)
{
using var host = Host.CreateDefaultBuilder(args)
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureLogging(lb =>
{
lb.ClearProviders();
lb.AddSimpleConsole(o =>
{
o.SingleLine = true;
o.TimestampFormat = "HH:mm:ss ";
});
lb.SetMinimumLevel(LogLevel.Warning);
})
.ConfigureServices((context, services) =>
{
services.AddWebServiceManagement(context.Configuration);
})
.Build();
using var cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) =>
{
e.Cancel = true;
cts.Cancel();
};
var dispatcher = host.Services.GetRequiredService<CommandDispatcher>();
return await dispatcher.DispatchAsync(args, cts.Token);
}
}