public static async Task StopAsync() { AppLogger.AddLog(LogProcess.System, null, "SYSTEM", "Start shutting down application"); AppGlobalFlags.IsShuttingDown = true; await _serviceProvider.GetRequiredService <ServicesDisposer>().Shutdown(); AppLogger.AddLog(LogProcess.System, null, "SYSTEM", "Everything stopped properly"); }
public override void OnException(ExceptionContext context) { //hata alındığında ne yapmak istiyorsan AppLogger.AddLog(new Data.Entities.Log { LogType = "Exception", Message = context.Exception.Message, Url = context.HttpContext.Request.Host.Value + context.HttpContext.Request.Path + context.HttpContext.Request.QueryString.Value }); base.OnException(context); }
public static void Init(IServiceProvider sp, SettingsModel settingsModel) { AppLogger = sp.GetRequiredService <IAppLogger>(); LogsSnapshotRepository = sp.GetRequiredService <LogsSnapshotRepository>(); var items = LogsSnapshotRepository.LoadAsync().AsTask().Result; ((AppLogger)AppLogger).Init(items); var queuesTimeSpan = TimeSpan.Parse(settingsModel.FlushQueuesSnapshotFreq); _taskTimerSyncQueues = new TaskTimer(queuesTimeSpan); var messagesTimeSpan = TimeSpan.Parse(settingsModel.FlushMessagesFreq); _taskTimerSyncMessages = new TaskTimer(messagesTimeSpan); AppGlobalFlags = sp.GetRequiredService <AppGlobalFlags>(); AppGlobalFlags.LoadBlobPagesSize = settingsModel.LoadBlobPagesSize; _serviceProvider = sp; QueueSnapshotCache = sp.GetRequiredService <QueueSnapshotCache>(); MessagesContentCache = sp.GetRequiredService <MessagesContentCache>(); MessagesContentReader = sp.GetRequiredService <MessagesContentReader>(); MetricsByTopic = sp.GetRequiredService <MetricsByTopic>(); _activePagesWarmerAndGc = sp.GetRequiredService <ActivePagesWarmerAndGc>(); TaskSchedulerByTopic = sp.GetRequiredService <TaskSchedulerByTopic>(); _queueSnapshotWriter = sp.GetRequiredService <QueueSnapshotWriter>(); CompressPageBlobOperation = sp.GetRequiredService <CompressPageBlobOperation>(); CompressedMessagesStorage = sp.GetRequiredService <ICompressedMessagesStorage>(); CompressedMessagesUtils = sp.GetRequiredService <CompressedMessagesUtils>(); LegacyCompressedMessagesStorage = sp.GetRequiredService <ILegacyCompressedMessagesStorage>(); MessagesContentPersistentStorage = sp.GetRequiredService <IMessagesContentPersistentStorage>(); ((MessagesPersistentStorage)MessagesContentPersistentStorage).Inject(sp); LastCompressedPageStorage = sp.GetRequiredService <ILastCompressedPageStorage>(); IndexByMinuteWriter = sp.GetRequiredService <IndexByMinuteWriter>(); SyncAndGcBlobOperations = sp.GetRequiredService <SyncAndGcBlobOperations>(); Task.Run(() => InitTopicsAsync(sp)); _taskTimerSyncQueues.Register("SyncQueuesSnapshotToStorage", _queueSnapshotWriter.ExecuteAsync); _taskTimerSyncQueues.Register("ActiveMessagesWarmerAndGc", _activePagesWarmerAndGc.CheckAndWarmItUpOrGcAsync); _taskTimerSyncQueues.Register("IndexByMinuteWriter", IndexByMinuteWriter.SaveMessagesToStorage); _taskTimerSyncQueues.Register("FlushLastCompressedPagesState", LastCompressedPageStorage.FlushAsync); _taskTimerSyncQueues.Register("Update prometheus", () => { MetricsCollector.UpdatePrometheus(); return(new ValueTask()); }); _taskTimerSyncQueues.RegisterExceptionHandler((timer, e) => { AppLogger.AddLog(LogProcess.System, timer, e.Message, e.StackTrace); return(new ValueTask()); }); _taskTimerSyncMessages.Register("PersistentOperationsScheduler", SyncAndGcBlobOperations.Sync); _taskTimerSyncMessages.RegisterExceptionHandler((timer, e) => { AppLogger.AddLog(LogProcess.System, timer, e.Message, e.StackTrace); return(new ValueTask()); }); }