Beispiel #1
0
        private static void Main()
        {
            Logger = LogManager.GetLogger(nameof(Program));

            //This is for one log file per run (based on start time...)
            NLog.GlobalDiagnosticsContext.Set("StartTime", DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss"));

            var configPath = Path.Combine(Environment.CurrentDirectory, "Chaos.json");

            if (File.Exists(configPath))
            {
                _chaosConfiguration = GetChaosConfiguration(configPath);
            }

            if (_chaosConfiguration == null)
            {
                // if GetChaosConfiguration fails (which it logs...), then exit...
                Logger?.Info("No configruration supplied... Exiting...");
                Environment.Exit(-1);
            }

            //Repeat setting
            if (_chaosConfiguration.Repeat > 0)
            {
                _repeat = _chaosConfiguration.Repeat;
            }

            //Start delay setting
            if (_chaosConfiguration.RunDelay > 0)
            {
                _runDelay = _chaosConfiguration.RunDelay;
            }

            try
            {
                //Must initialize Bedlam with a ChaosConfiguration...
                _bedlam = new Bedlam(_chaosConfiguration);
            }
            catch (Exception e)
            {
                Logger?.Info("Error initializing Bedlam: " + e.Message + "\n Exiting...");
                Logger?.Error(e);
                Environment.Exit(-1);
            }

            for (int i = 0; i < _repeat + 1; i++)
            {
                if (_runDelay > 0)
                {
                    Thread.Sleep(_runDelay * 1000);
                }

                _bedlam.Run();
            }
        }
Beispiel #2
0
        private static void Main()
        {
            Logger = LogManager.GetLogger(nameof(Program));

            var configPath = Path.Combine(Environment.CurrentDirectory, "Chaos.config");

            if (File.Exists(configPath))
            {
                _chaosConfiguration = GetChaosConfiguration(configPath);
            }

            if (_chaosConfiguration == null)
            {
                // if GetChaosConfiguration fails (which it logs...), then exit...
                Logger?.Info("No configruration supplied... Exiting...");
                Environment.Exit(-1);
            }

            //Repeat setting
            if (_chaosConfiguration.Repeat > 0)
            {
                _repeat = _chaosConfiguration.Repeat;
            }

            //Start delay setting
            if (_chaosConfiguration.RunDelay > 0)
            {
                _runDelay = _chaosConfiguration.RunDelay;
            }

            try
            {
                //Must initialize Bedlam instance with ChaosConfiguration instance...
                _bedlam = new Bedlam(_chaosConfiguration);
            }
            catch (Exception e)
            {
                Logger?.Info("Error initializing Bedlam: " + e.Message + "\n Exiting...");
                Environment.Exit(-1);
            }

            for (int i = 0; i < _repeat + 1; i++)
            {
                if (_runDelay > 0)
                {
                    Thread.Sleep(_runDelay * 1000);
                }
                _bedlam.Run();
            }
        }