protected DedicatedServerAssemblyWrapper( )
		{
			_instance = this;

			string assemblyPath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "VRage.Dedicated.dll" );
			_assembly = Assembly.UnsafeLoadFrom( assemblyPath );

			ApplicationLog.BaseLog.Info( "Finished loading DedicatedServerAssemblyWrapper" );
		}
        protected DedicatedServerAssemblyWrapper( )
        {
            _instance = this;

            //string assemblyPath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "VRage.Dedicated.dll" );
            //_assembly = Assembly.UnsafeLoadFrom( assemblyPath );

            ApplicationLog.BaseLog.Info("Finished loading DedicatedServerAssemblyWrapper");
        }
Example #3
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;
			}
		}
Example #4
0
		private bool SetupManagers( )
		{
			_dedicatedServerWrapper = DedicatedServerAssemblyWrapper.Instance;
			_pluginManager = PluginManager.Instance;
			_factionsManager = FactionsManager.Instance;
			_entityEventManager = EntityEventManager.Instance;
			_chatManager = ChatManager.Instance;
			_sessionManager = SessionManager.Instance;

			return true;
		}