private void Shutdown() { this.StopAllModules(); this.DisposeAllScouts(); this.Dispose(); if(homeService!=null) homeService.Stop(); this.runningScouts = null; this.runningModules = null; this.runningModulesStates = null; this.registeredPorts = null; this.registeredPorts = null; this.config = null; this.allAddinTokens = null; this.policyEngine = null; //this.gadgetListener = null; this.guiService = null; this.homeService = null; this.infoService = null; this.discoveryHelperService = null; this.heartbeatService = null; this.random = null; GC.Collect(); //finally close the logger object if (logger != null) logger.Close(); }
/// <summary> /// Start the platform /// </summary> public void Start() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(LogUnhandledException); AppDomain.MonitoringIsEnabled = true; // cache the version this.platformVersion = Utils.GetHomeOSUpdateVersion(this.GetType().Assembly.CodeBase + ".config", logger); //start the basic services infoService = new InfoService(this, logger); guiService = new GuiService(this, config, homeStoreInfo, logger); discoveryHelperService = new DiscoveryHelper(this, logger); if (!guiService.IsConfigNeeded()) { ConfiguredStart(); } if (!Settings.RunningMode.Equals("unittesting", StringComparison.CurrentCultureIgnoreCase)) { if (Environment.UserInteractive) { ReadCommandsFromConsole(); } else { // wait indefinitely, once we support Stop() on the platform this event // will be signalled, which will be needed for Updating the the Platform itself this.eventPlatformStopped = new AutoResetEvent(false); this.eventPlatformStopped.WaitOne(); } } }
private void Initialize(string[] arguments) { safeToGoOnline = false; guiService = null; homeService = null; //initialize various data structures random = new Random(); runningModules = new Dictionary<VModule, ModuleInfo>(); runningScouts = new Dictionary<string, Tuple<ScoutInfo, IScout>>(); runningModulesStates = new Dictionary<VModule, VModuleState>(); registeredPorts = new Dictionary<VPort, VModule>(); //this initializes the settings to what was default (in the code) Settings.Initialize(); ArgumentsDictionary argsDict = ProcessArguments(arguments); //were we supplied a non-default configuration directory? if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict["ConfigDir"])) Settings.SetParameter("ConfigDir", (string) argsDict["ConfigDir"]); //this overwrites the settings to what was in the configuration file config = new Configuration(Settings.ConfigDir); config.ParseSettings(); //now, overwrite the settings with those on the command line foreach (var parameter in argsDict.Keys) { if (parameter.Equals("Help")) continue; if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict[parameter])) config.UpdateConfSetting(parameter, argsDict[parameter]); } //initialize the logger logger = InitLogger(Settings.LogFile); logger.Log("Platform initialized"); //set the logger for config and read remaining config fines config.SetLogger(logger); config.ReadConfiguration(); //initialize the policy enginer policyEngine = new PolicyEngine(logger); policyEngine.Init(config); //rebuild the addin tokens this.rebuildAddInTokens(); homeStoreInfo = new HomeStoreInfo(logger); _consoleHandler = new PlatformConsoleCtrlHandlerDelegate(ConsoleEventHandler); SetConsoleCtrlHandler(_consoleHandler, true); }