internal Core(string[] args) { Console.Title = $"Initializing..."; Logger = InternalLogger.GetOrCreateLogger <Core>(this, nameof(Core)); OS.Init(true); RuntimeSpanCounter.Restart(); File.WriteAllText("version.txt", Constants.Version?.ToString()); ParseStartupArguments(); if (File.Exists(Constants.TraceLogFile)) { File.Delete(Constants.TraceLogFile); } Config = new CoreConfig(this); Config.LoadAsync().Wait(); IsUpdatesAllowed = !NoUpdates && Config.AutoUpdates; Config.LocalIP = Helpers.GetLocalIpAddress()?.ToString() ?? "-Invalid-"; Config.PublicIP = Helpers.GetPublicIP()?.ToString() ?? "-Invalid-"; if (!IsNetworkAvailable) { Logger.Warn("No Internet connection."); Logger.Info($"Starting offline mode..."); } Pins = new PinsWrapper( Config.GpioConfiguration.OutputModePins, Config.GpioConfiguration.InputModePins, Constants.BcmGpioPins, Config.GpioConfiguration.RelayPins, Config.GpioConfiguration.InfraredSensorPins, Config.GpioConfiguration.SoundSensorPins ); Controller = new GpioCore(Pins, this, Config.GpioConfiguration.GpioSafeMode); ModuleLoader = new ModuleLoader(); RestServer = new RestCore(Config.RestServerPort, Config.Debug); JobManager.AddJob(() => SetConsoleTitle(), (s) => s.WithName("ConsoleUpdater").ToRunEvery(1).Seconds()); Logger.CustomLog(FiggleFonts.Ogre.Render("LUNA"), ConsoleColor.Green); Logger.CustomLog($"---------------- Starting Luna v{Constants.Version} ----------------", ConsoleColor.Blue); IsBaseInitiationCompleted = true; PostInitiation().Wait(); InternalConfigWatcher = new ConfigWatcher(this); InternalModuleWatcher = new ModuleWatcher(this); InitiationCompleted = true; }
public Core StartWatcher() { FileWatcher.InitWatcher(Constants.ConfigDirectory, new Dictionary <string, Action>() { { "Assistant.json", new Action(OnCoreConfigChangeEvent) }, { "DiscordBot.json", new Action(OnDiscordConfigChangeEvent) }, { "MailConfig.json", new Action(OnMailConfigChangeEvent) } }, new List <string>(), "*.json", false); ModuleWatcher.InitWatcher(Constants.ModuleDirectory, new List <Action <string> >() { new Action <string>((x) => OnModuleDirectoryChangeEvent(x)) }, new List <string>(), "*.dll", false); return(this); }