Dev2.ServerLifecycleManager.Run C# (CSharp) Method

Run() private method

Runs the application server, and handles all initialization, execution and cleanup logic required.
private Run ( bool interactiveMode ) : int
interactiveMode bool
return int
        int Run(bool interactiveMode)
        {
            int result = 0;
            bool didBreak = false;

            Tracker.StartServer();

            // ** Perform Moq Installer Actions For Development ( DEBUG config ) **
#if DEBUG
            try
            {
                var miq = MoqInstallerActionFactory.CreateInstallerActions();
                miq.ExecuteMoqInstallerActions();
            }
            catch(Exception e)
            {
                // Throw new exception to make it easy for developer to understand issue
                throw new Exception("Ensure you are running as an Administrator. Mocking installer actions for DEBUG config failed to create Warewolf Administrators group and/or to add current user to it [ " + e.Message + " ]");
            }
#endif


            if(!SetWorkingDirectory())
            {
                result = 95;
                didBreak = true;
            }

            // PBI 5389 - Resources Assigned and Allocated to Server
            if(!didBreak && !LoadHostSecurityProvider())
            {
                result = 1;
                didBreak = true;
            }

            if(!didBreak && !LoadConfiguration(_configFile))
            {
                result = 1;
                didBreak = true;
            }

            // remove due to hanging installer ;) 02.04.2014
            if(!didBreak && !PreloadReferences())
            {
                result = 2;
                didBreak = true;
            }

            if(!didBreak && !StartGcManager())
            {
                result = 7;
                didBreak = true;
            }

            if(!didBreak && !InitializeServer())
            {
                result = 3;
                didBreak = true;
            }

            if(!didBreak && !LoadResourceCatalog())
            {
                result = 94;
                didBreak = true;
            }


            // PBI 5389 - Resources Assigned and Allocated to Server
            if(!didBreak && !LoadServerWorkspace())
            {
                result = 98; // ????
                didBreak = true;
            }

            if(!didBreak && !StartWebServer())
            {
                result = 4;
                didBreak = true;
            }

            // PBI 1018 - Settings Framework (TWR: 2013.03.07)
            if(!didBreak && !LoadSettingsProvider())
            {
                result = 93;
                didBreak = true;
            }

            if(!didBreak && !ConfigureLoggging())
            {
                result = 92;
                didBreak = true;
            }


            if(!didBreak)
            {
                // set background timer to query network computer name list every 15 minutes ;)
                _timer = new Timer(PerformTimerActions, null, 1000, GlobalConstants.NetworkComputerNameQueryFreq);
                result = ServerLoop(interactiveMode);
                StartPulseLogger();
            }
            else
            {
                result = Stop(true, result);
            }

            return result;
        }

Usage Example

        static int RunMain(string[] arguments)
        {
            const int Result = 0;

            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                Dev2Logger.Fatal("Server has crashed!!!", args.ExceptionObject as Exception, "Warewolf Fatal");
            };
            if (Environment.UserInteractive || (arguments.Count() > 0 && arguments[0] == "--interactive"))
            {
                Dev2Logger.Info("** Starting In Interactive Mode **", GlobalConstants.WarewolfInfo);
                using (_singleton = new ServerLifecycleManager(arguments))
                {
                    _singleton.Run(true);
                }

                _singleton = null;
            }
            else
            {
                Dev2Logger.Info("** Starting In Service Mode **", GlobalConstants.WarewolfInfo);
                using (var service = new ServerLifecycleManagerService())
                {
                    ServiceBase.Run(service);
                }
            }
            return(Result);
        }
All Usage Examples Of Dev2.ServerLifecycleManager::Run