private static void Run(RunOptions options) { var log = new ConsoleLog(); var instance = new TerabInstance(log); var config = new TerabConfig { Layer1Path = options.Layer1Path, Layer3Path = string.Empty, Port = 0, // auto-selecting port }; instance.SetupStores(config); instance.SetupNetwork(config); instance.SetupControllers(); try { instance.Start(); Thread.Sleep(500); var localEndpoint = new IPEndPoint(IPAddress.Loopback, instance.Port); DoBenchmark(localEndpoint, log); } finally { instance.Stop(); } }
public static void Run(RunOptions options) { _log = new ConsoleLog(); _log.Log(LogSeverity.Info, " ### Running the server ### "); _log.Log(LogSeverity.Info, $" ProcessID: {Process.GetCurrentProcess().Id}"); var config = TerabConfigReader.Read(options.ConfigFullPath); var terab = new TerabInstance(_log); terab.SetupNetwork(config); terab.SetupStores(config); terab.SetupControllers(); _log.Log(LogSeverity.Info, $"Starting the server listening to {config.IpAddress} on port {config.Port}"); terab.Start(); _log.Log(LogSeverity.Info, $"Server started - press Ctrl-C to exit"); AppDomain.CurrentDomain.ProcessExit += (sender, args) => _log.Log(LogSeverity.Info, "App domain exit"); var readLoop = new CancellationTokenSource(); Console.CancelKeyPress += (o, args) => { terab.Stop(); readLoop.Cancel(); }; try { while (!readLoop.IsCancellationRequested) { Console.ReadKey(); } } catch (Exception e) { _log.Log(LogSeverity.Error, "an error occurred"); _log.Log(LogSeverity.Error, e.Message); } finally { _log.Log(LogSeverity.Info, "bye bye"); } }