-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (63 loc) · 2.18 KB
/
Program.cs
File metadata and controls
67 lines (63 loc) · 2.18 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Fivet.Dao;
using Fivet.ZeroIce;
using Fivet.ZeroIce.model;
namespace Fivet.Server
{
class Program
{
/// <summary>
/// Main stating point.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
/// <summary>
/// Build and configure a Host.
/// </summary>
/// <param name="args"></param>
/// <returns>The IHostBuilder</returns>
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host
.CreateDefaultBuilder(args)
// Development, Staging, Production
.UseEnvironment("Development")
// Logging configuration
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole(options =>
{
options.IncludeScopes = true;
options.TimestampFormat = "[yyyy-MM-dd HH:mm:ss.fff]";
options.DisableColors = false;
});
logging.SetMinimumLevel(LogLevel.Trace);
})
// Enable Control+C listener
.UseConsoleLifetime()
// Service inside the DI
.ConfigureServices((hostContext, services) =>
{
// The system
services.AddSingleton<TheSystemDisp_, TheSystemImpl>();
// Contratos
services.AddSingleton<ContratosDisp_, ContratosImpl>();
// The FivetContext
services.AddDbContext<FivetContext>();
// The FivetService
services.AddHostedService<FivetService>();
// The Logger
services.AddLogging();
// The wait for finish
services.Configure<HostOptions>(option =>
{
option.ShutdownTimeout = System.TimeSpan.FromSeconds(15);
});
});
}
}