Beispiel #1
0
        static int Main(string[] args)
        {
            // Load configuration options.
            string pluginDir = null;

            string[] pluginWhiteList = null;
            string[] pluginBlackList = null;
            try {
                pluginDir = LoadPluginConfig(ref pluginWhiteList, ref pluginBlackList);
            } catch (ConfigurationErrorsException) {
                logger.Error("Configuration is missing or corrupt.");
            }

            logger.Info("Loading plugins");
            if (pluginDir != null && Directory.Exists(pluginDir))
            {
                PluginManager.Instance.LoadPluginsFrom(pluginDir, pluginWhiteList, pluginBlackList);
                if (PluginManager.Instance.DeferredPlugins.Count > 0)
                {
                    logger.Info(CreateDeferredPluginsLogEntry());
                }
            }
            else
            {
                logger.Error("Plugin dir is not specified or does not exist");
            }

            var           loadedPlugins     = new List <PluginManager.PluginInfo>(PluginManager.Instance.LoadedPlugins);
            List <string> loadedPluginNames = loadedPlugins.ConvertAll(info => info.Name);

            logger.Info("Initialized plugins: " + String.Join(", ", loadedPluginNames));

            PluginManager.Instance.OnAnyPluginInitialized += HandlePluginInitialized;

            if (Controller == null)
            {
                // Wait for 'q' key to be pressed.
                Console.WriteLine("The server is up and running. Press 'q' to stop it...");
                while (Console.ReadKey().KeyChar != 'q')
                {
                    ;
                }
            }
            else
            {
                Controller.WaitForTerminate();
            }

            PluginManager.Instance.ShutdownAllPlugins();

            return(0);
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            // Load configuration options.
            string pluginDir = null;

            string[] pluginWhiteList = null;
            string[] pluginBlackList = null;
            try
            {
                pluginDir = LoadPluginConfig(ref pluginWhiteList, ref pluginBlackList);
            }
            catch (ConfigurationErrorsException)
            {
                logger.Error("Configuration is missing or corrupt.");
            }

            logger.Info("Loading plugins");
            if (pluginDir != null && Directory.Exists(pluginDir))
            {
                PluginManager.Instance.LoadPluginsFrom(pluginDir, pluginWhiteList, pluginBlackList);
                if (PluginManager.Instance.DeferredPlugins.Count > 0)
                {
                    logger.Info(CreateDeferredPluginsLogEntry());
                }
            }
            else
            {
                logger.Error("Plugin dir is not specified or does not exist");
            }

            var           loadedPlugins     = new List <PluginManager.PluginInfo>(PluginManager.Instance.LoadedPlugins);
            List <string> loadedPluginNames = loadedPlugins.ConvertAll(info => info.Name);

            logger.Info("Initialized plugins: " + String.Join(", ", loadedPluginNames));

            PluginManager.Instance.OnAnyPluginInitialized += HandlePluginInitialized;

            Controller.NotifyPluginsLoaded();

            if (!Controller.ControlTaken)
            {
                Console.WriteLine("The server is up and running. Send a shutdown signal, use CTRL+C, or close this window to stop it");
            }

            Controller.WaitForTerminate();

            PluginManager.Instance.ShutdownAllPlugins();

            return(0);
        }