Shutdown() публичный Метод

public Shutdown ( ) : void
Результат void
Пример #1
0
        private void RunServer()
        {
            if (m_restartLimit < 0)
            {
                return;
            }

            m_lastRestart = DateTime.Now;

            try
            {
                bool result = m_serverWrapper.StartServer(m_commandLineArgs.instanceName, m_commandLineArgs.path, !m_commandLineArgs.noConsole);

                m_isServerRunning = false;

                m_pluginMainLoop.Stop();
                m_autosaveTimer.Stop();

                m_pluginManager.Shutdown();

                Console.WriteLine("Server has stopped running");

                /*
                 * if (!result)
                 * {
                 *      LogManager.APILog.WriteLineAndConsole("Server crashed, attempting auto-restart ...");
                 *
                 *      TimeSpan timeSinceLastRestart = DateTime.Now - m_lastRestart;
                 *
                 *      //Reset the restart limit if the server has been running for more than 5 minutes before the crash
                 *      if (timeSinceLastRestart.TotalMinutes > 5)
                 *              m_restartLimit = 3;
                 *
                 *      m_restartLimit--;
                 *
                 *      m_isServerRunning = true;
                 *      SectorObjectManager.Instance.IsShutDown = false;
                 *
                 *      m_runServerThread = new Thread(new ThreadStart(this.RunServer));
                 *      m_runServerThread.Start();
                 * }*/
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
            }
        }
Пример #2
0
        private void RunServer( )
        {
            if (_restartLimit < 0)
            {
                return;
            }

            try
            {
                ExtenderOptions.InstanceName = InstanceName;
                _dedicatedServerWrapper      = DedicatedServerAssemblyWrapper.Instance;
                bool result = _dedicatedServerWrapper.StartServer(_commandLineArgs.InstanceName, _commandLineArgs.InstancePath, !_commandLineArgs.NoConsole);
                ApplicationLog.BaseLog.Info("Server has stopped running");

                _isServerRunning = false;

                _pluginMainLoop.Stop( );
                _autosaveTimer.Stop( );

                _pluginManager.Shutdown( );

                if (!result && _commandLineArgs.CloseOnCrash)
                {
                    Thread.Sleep(5000);
                    Environment.Exit(1);
                }

                if (!result && _commandLineArgs.RestartOnCrash)
                {
                    Thread.Sleep(5000);

                    string restartText = "timeout /t 20\r\n";
                    restartText += string.Format("cd /d \"{0}\"\r\n", System.IO.Path.GetDirectoryName(Application.ExecutablePath));
                    restartText += string.Format("{0} {1}\r\n", System.IO.Path.GetFileName(Application.ExecutablePath), _commandLineArgs.Args);

                    File.WriteAllText("RestartApp.bat", restartText);
                    Process.Start("RestartApp.bat");
                    Environment.Exit(1);
                }

                /*
                 * if (!result)
                 * {
                 *      LogManager.APILog.WriteLineAndConsole("Server crashed, attempting auto-restart ...");
                 *
                 *      TimeSpan timeSinceLastRestart = DateTime.Now - m_lastRestart;
                 *
                 *      //Reset the restart limit if the server has been running for more than 5 minutes before the crash
                 *      if (timeSinceLastRestart.TotalMinutes > 5)
                 *              _restartLimit = 3;
                 *
                 *      _restartLimit--;
                 *
                 *      _isServerRunning = true;
                 *      SectorObjectManager.Instance.IsShutDown = false;
                 *
                 *      _runServerThread = new Thread(new ThreadStart(this.RunServer));
                 *      _runServerThread.Start();
                 * }*/
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
            finally
            {
                _dedicatedServerWrapper = null;
            }
        }
Пример #3
0
        private void RunServer()
        {
            if (m_restartLimit < 0)
            {
                return;
            }

            m_lastRestart = DateTime.Now;

            try
            {
                SandboxGameAssemblyWrapper.InstanceName = InstanceName;
                m_serverWrapper = ServerAssemblyWrapper.Instance;
                bool result = m_serverWrapper.StartServer(m_commandLineArgs.instanceName, m_commandLineArgs.path, !m_commandLineArgs.noConsole);
                Console.WriteLine("Server has stopped running");

                m_isServerRunning = false;

                m_pluginMainLoop.Stop();
                m_autosaveTimer.Stop();

                m_pluginManager.Shutdown();

                if (!result && m_commandLineArgs.closeOnCrash)
                {
                    Thread.Sleep(5000);
                    Environment.Exit(1);
                }

                if (!result && m_commandLineArgs.restartOnCrash)
                {
                    Thread.Sleep(5000);

                    String restartText = "timeout /t 20\r\n";
                    restartText += String.Format("cd /d \"{0}\"\r\n", System.IO.Path.GetDirectoryName(Application.ExecutablePath));
                    restartText += System.IO.Path.GetFileName(Application.ExecutablePath) + " " + m_commandLineArgs.args + "\r\n";

                    File.WriteAllText("RestartApp.bat", restartText);
                    System.Diagnostics.Process.Start("RestartApp.bat");
                    Environment.Exit(1);
                }

                /*
                 * if (!result)
                 * {
                 *      LogManager.APILog.WriteLineAndConsole("Server crashed, attempting auto-restart ...");
                 *
                 *      TimeSpan timeSinceLastRestart = DateTime.Now - m_lastRestart;
                 *
                 *      //Reset the restart limit if the server has been running for more than 5 minutes before the crash
                 *      if (timeSinceLastRestart.TotalMinutes > 5)
                 *              m_restartLimit = 3;
                 *
                 *      m_restartLimit--;
                 *
                 *      m_isServerRunning = true;
                 *      SectorObjectManager.Instance.IsShutDown = false;
                 *
                 *      m_runServerThread = new Thread(new ThreadStart(this.RunServer));
                 *      m_runServerThread.Start();
                 * }*/
            }
            catch (Exception ex)
            {
                Console.WriteLine("Uncaught");
                LogManager.ErrorLog.WriteLine(ex);
            }
            finally
            {
                m_serverWrapper = null;
            }
        }