-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (72 loc) · 2.54 KB
/
Program.cs
File metadata and controls
82 lines (72 loc) · 2.54 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Collections.Concurrent;
using Couchbase.Analytics.Performer.Internal.Connections;
using Couchbase.Analytics.Performer.Internal.Logging;
using Couchbase.Analytics.Performer.Internal.Services;
using Couchbase.Grpc.Protocol.Columnar;
using Grpc.Core;
using Serilog;
namespace Couchbase.Analytics.Performer;
public class Program
{
private static ConcurrentDictionary<string, ClusterConnection> _clusters = new();
public static async Task Main(string[] args)
{
var loggerFactory = LoggingUtils.ConfigureLogging(out var minimumLevel);
bool disableConsoleRead = false;
foreach (var arg in args)
{
var parameter = arg.Split(new[] { '=' }, 2);
if (parameter.Length == 2)
{
switch (parameter[0])
{
case "disableConsoleRead":
if (bool.TryParse(parameter[1], out var parsedDisableConsoleRead))
{
disableConsoleRead = parsedDisableConsoleRead;
}
break;
}
}
}
var (host, port) = ("localhost", 8060);
var server = new Server
{
Ports =
{
new ServerPort(host, port, ServerCredentials.Insecure)
},
Services =
{
ColumnarService.BindService(new AnalyticsPerformerService(_clusters)),
ColumnarCrossService.BindService(new AnalyticsPerformerCrossService(_clusters))
}
};
server.Start();
Log.Information(".NET Analytics Performer started on {Host}:{Port} at LogLevel {Level}", host, port, minimumLevel);
if (disableConsoleRead)
{
Log.Information("Running in headless mode, waiting for shutdown signal");
var shutdownEvent = new ManualResetEventSlim(false);
Console.CancelKeyPress += (_, e) =>
{
e.Cancel = true;
shutdownEvent.Set();
};
AppDomain.CurrentDomain.ProcessExit += (_, _) => shutdownEvent.Set();
shutdownEvent.Wait();
}
else
{
Log.Information("Press any key to stop the server");
Console.ReadKey();
}
await server.ShutdownAsync().ConfigureAwait(false);
LoggingUtils.ShutdownLogging();
if (!disableConsoleRead)
{
Log.Information("Press any key to exit");
Console.ReadKey();
}
}
}