46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using ClientTester.EchoDummyService;
|
|
using Serilog;
|
|
|
|
class EcoClientTester
|
|
{
|
|
public static readonly string SERVER_IP = "localhost";
|
|
public static readonly int SERVER_PORT = 9500;
|
|
public static readonly string CONNECTION_KEY = "test";
|
|
public static readonly int CLIENT_COUNT = 100;
|
|
|
|
private static async Task Main(string[] args)
|
|
{
|
|
// .MinimumLevel.Warning() // Warning 이상만 출력 배포시
|
|
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
|
|
|
Log.Logger = new LoggerConfiguration()
|
|
.MinimumLevel.Debug()
|
|
.WriteTo.Console()
|
|
.WriteTo.File($"logs/log_{timestamp}.txt")
|
|
.CreateLogger();
|
|
|
|
CancellationTokenSource cts = new CancellationTokenSource();
|
|
Console.CancelKeyPress += (_, e) =>
|
|
{
|
|
e.Cancel = true;
|
|
Log.Warning("[SHUTDOWN] Ctrl+C 감지, 종료 중...");
|
|
cts.Cancel();
|
|
};
|
|
|
|
DummyClientService service = new DummyClientService(CLIENT_COUNT, SERVER_IP, SERVER_PORT, CONNECTION_KEY, 100);
|
|
service.OnAllDisconnected += async () =>
|
|
{
|
|
Log.Warning("[SHUTDOWN] 종료 이벤트 발생, 종료 중...");
|
|
await cts.CancelAsync();
|
|
};
|
|
|
|
await service.RunAsync(cts.Token);
|
|
|
|
service.PrintStats();
|
|
service.Stop();
|
|
|
|
await Log.CloseAndFlushAsync();
|
|
}
|
|
}
|