Meum/Meum.Server/Program.cs
2025-07-05 01:21:18 +03:00

50 lines
1.3 KiB
C#

global using System;
global using System.Collections.Generic;
global using System.Threading;
global using System.Threading.Tasks;
global using Meum.Core;
using DTLib.Console;
using DTLib.Demystifier;
using DTLib.Filesystem;
using DTLib.Logging;
namespace Meum.Server;
static class Program
{
static readonly IOPath config_path = "Meum.Server.config.json";
static async Task Main(string[] args)
{
try
{
var config = ServerConfig.LoadOrCreate(config_path);
var logger = new CompositeLogger(
new ConsoleLogger(),
new FileLogger("logs", "meum-server"));
Functions.InitMsQuic(logger);
var server = new Server(config, logger);
await server.ListenAsync();
while (true)
{
try
{
var conn = await server.AcceptConnectionAsync();
}
catch (Exception ex)
{
logger.LogError("MainLoop", ex);
}
}
}
catch (Exception ex)
{
ColoredConsole.WriteLine(ex.ToStringDemystified(), ConsoleColor.Red);
}
finally
{
Console.ResetColor();
}
}
}