public bool Start(HostControl hostControl) { try { log.Information("Configuring container"); ConfigureContainer(); log.Information("Starting service"); ProcessPriorityHelper.SetMemoryPriority(ProcessMemoryPriority.Normal, new SerilogLog(log)); ProcessPriorityHelper.SetProcessPriorityClass(ProcessPriorityClass.Normal, new SerilogLog(log)); if (!settings.TryGetInt("ThreadMultiplier", out var threadMultiplier)) { threadMultiplier = 16; log.Warning("`ThreadMultiplier` setting not found. Use multiplier {multiplier}", threadMultiplier); } ThreadPoolUtility.SetUp(new SerilogLog(log), threadMultiplier); StartChildServices(); log.Information("Service is started"); Console.WriteLine("Service is started"); return(true); } catch (Exception e) { log.Error(e, "Unexpected error while starting service"); (log as IDisposable)?.Dispose(); throw; } }
private void SetUpServices(IAppBuilder appBuilder, Container container) { var log = container.GetInstance <ILog>(); var serviceSettings = container.GetInstance <IServiceSettings>(); ProcessPriorityHelper.SetMemoryPriority(ProcessMemoryPriority.Normal, log); ProcessPriorityHelper.SetProcessPriorityClass(ProcessPriorityClass.Normal, log); ThreadPoolUtility.SetUp(log, serviceSettings.GetThreadMultiplier()); var serviceBeacon = new ServiceBeacon(log, serviceSettings.GetPort()); serviceBeacon.Start(); var metricsWorker = container.GetInstance <MetricsWorker>(); metricsWorker.Start(); appBuilder.OnDisposing( () => { serviceBeacon.Stop(); metricsWorker.Stop(); }); }