Пример #1
0
        static void Main(string[] args)
        {
            bool   shouldShowHelp = false;
            string pipelineFile   = Path.Combine(Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]), "Pipelines", "MasterPipeline.meep");
            string redisHost      = "localhost";

            var options = new OptionSet
            {
                { "p|pipeline=", "Path to pipeline file", p => pipelineFile = p },
                { "q|quiet", "No gutter serialisation", g => GutterSerialisation = GutterSerialisation.None },
                { "x|xml", "Gutter serialisation in XML", g => GutterSerialisation = GutterSerialisation.XML },
                { "b|bson", "Gutter serialisation in BSON", b => GutterSerialisation = GutterSerialisation.BSON },
                { "r|redis=", "Redis server hostname[:port]", r => redisHost = r },
                { "h|help", "show this message and exit", h => shouldShowHelp = h != null },
            };

            List <string> extra;

            try
            {
                extra = options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Console.Write("meep: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `meep --help' for more information.");
                return;
            }

            if (shouldShowHelp)
            {
                ShowHelp();
            }

            LoadBasePlugins();

            IConnectionMultiplexer multiplexer = null;

            try
            {
                multiplexer = ConnectionMultiplexer.Connect(redisHost);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} thrown connecting to Redis. Continuing without. ({1})", ex.GetType().Name, ex.Message);
            }
            var proxy = new HostProxy(multiplexer);

            Bootstrapper = new Bootstrapper(pipelineFile);
            Bootstrapper.PipelineRefreshed += Bootstrapper_PipelineRefreshed;
            Bootstrapper.Start();

            System.Threading.ManualResetEvent resetEvent = new System.Threading.ManualResetEvent(false);
            resetEvent.WaitOne();

            Bootstrapper.Stop();
            Subscription?.Dispose();
        }
Пример #2
0
        /// <summary>
        /// Main() for User Interactive mode (command line)
        /// </summary>
        /// <param name="args"></param>
        public static void InteractiveMain(LaunchOptions options)
        {
            if (options.Help)
            {
                ShowHelp();
            }

            if (options.ListBooks)
            {
                ShowLibrary();
            }

            LoadBasePlugins();

            var proxy = new HostProxy();

            if (String.IsNullOrWhiteSpace(options.GitRepository))
            {
                if (File.Exists(options.PipelineURI))
                {
                    Bootstrapper = new Bootstrapper(options.PipelineURI);
                }
                else
                {
                    Console.WriteLine("Couldn't find a pipeline definition at {0}", options.PipelineURI);
                    Console.WriteLine("Either create one at the default location (Pipelines/MasterPipeline.meep) or specify it with -p path/to/pipeline.meep");
                    Console.WriteLine("Try `meep --help' for more information.");
                    return;
                }
            }
            else
            {
                Bootstrapper = new Bootstrapper(new Uri(options.GitRepository), options.PipelineURI, options.RecheckInterval);
            }

            try
            {
                stoppingTokenSource             = new CancellationTokenSource();
                Bootstrapper.PipelineRefreshed += Bootstrapper_PipelineRefreshed;

                Bootstrapper.Start(stoppingTokenSource.Token);

                System.Threading.ManualResetEvent resetEvent = new System.Threading.ManualResetEvent(false);
                resetEvent.WaitOne();

                stoppingTokenSource.Cancel();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (System.Environment.UserInteractive)
                {
                    Console.ReadKey();
                }
                throw;
            }
        }