Esempio n. 1
0
        public static void Exit(bool quickShutdown)
        {
            if (quickShutdown)
            {
                GracefullModuleShutdown = false;

                if (Controller != null)
                {
                    Controller.InitGpioShutdownTasks();
                }

                if (TaskManager != null)
                {
                    TaskManager.OnCoreShutdownRequested();
                }

                if (Update != null)
                {
                    Update.StopUpdateTimer();
                    Logger.Log("Update timer disposed!", Enums.LogLevels.Trace);
                }

                if (RefreshConsoleTitleTimer != null)
                {
                    RefreshConsoleTitleTimer.Dispose();
                    Logger.Log("Console title refresh timer disposed!", Enums.LogLevels.Trace);
                }

                Logger.Log("Bye, Sorry to see you go so fast!");
                Logging.LoggerOnShutdown();
                Environment.Exit(0);
            }
        }
Esempio n. 2
0
        public static async Task OnExit()
        {
            Logger.Log("Shutting down...");
            if (ModuleLoader != null)
            {
                await ModuleLoader.ExecuteAsyncEvent(Enums.AsyncModuleContext.AssistantShutdown).ConfigureAwait(false);
            }

            if (TaskManager != null)
            {
                TaskManager.OnCoreShutdownRequested();
            }

            if (Update != null)
            {
                Update.StopUpdateTimer();
                Logger.Log("Update timer disposed!", Enums.LogLevels.Trace);
            }

            if (RefreshConsoleTitleTimer != null)
            {
                RefreshConsoleTitleTimer.Dispose();
                Logger.Log("Console title refresh timer disposed!", Enums.LogLevels.Trace);
            }

            if (ConfigWatcher != null && ConfigWatcher.ConfigWatcherOnline)
            {
                ConfigWatcher.StopConfigWatcher();
            }

            if (ModuleWatcher != null && ModuleWatcher.ModuleWatcherOnline)
            {
                ModuleWatcher.StopModuleWatcher();
            }

            if (AssistantStatus != null)
            {
                AssistantStatus.Dispose();
            }

            if (KestrelServer.IsServerOnline)
            {
                await KestrelServer.Stop().ConfigureAwait(false);
            }

            if (ModuleLoader != null)
            {
                ModuleLoader.OnCoreShutdown();
            }

            if (Controller != null)
            {
                Controller.InitGpioShutdownTasks();
            }

            if (Config != null)
            {
                Config.ProgramLastShutdown = DateTime.Now;
                Config.SaveConfig(Config);
            }

            Logger.Log("Finished on exit tasks.", Enums.LogLevels.Trace);
        }