Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World! Starting cluster...");

            ILoggerFactory loggerFactory =
                LoggerFactory.Create(builder => { builder.AddConsole(); });

            Log.SetLoggerFactory(loggerFactory);

            Cluster cluster = new Cluster();

            // Test process that becomes unhealthy after 75 seconds
            LocalProcess localProcessWithBadHealth = GetWorkerProcess(5432, 75);

            cluster.Add(localProcessWithBadHealth);

            // Test recycling by cluster after 3 minutes
            LocalProcess localProcessWithGoodHealth = GetWorkerProcess(5433, -1);

            localProcessWithGoodHealth.RecyclingIntervalHours = 0.05;
            cluster.Add(localProcessWithGoodHealth);

            // Test recycling for busy process after 4.5 minutes
            LocalProcess localProcessWithGoodHealthButAlwaysBusy = GetWorkerProcess(5434, -1, 1);

            localProcessWithGoodHealthButAlwaysBusy.RecyclingIntervalHours = 0.075;
            cluster.Add(localProcessWithGoodHealthButAlwaysBusy);

            _ = cluster.StartAsync();

            Console.WriteLine("Press any key to finish");

            Console.ReadKey();

            cluster.Abort();
        }