Exemplo n.º 1
0
 public void SimpleLayoutCachingTest()
 {
     var l = new SimpleLayout("xx${level}yy");
     var ev = LogEventInfo.CreateNullEvent();
     string output1 = l.Render(ev);
     string output2 = l.Render(ev);
     Assert.AreSame(output1, output2);
 }
Exemplo n.º 2
0
 public void LayoutRendererThrows()
 {
     ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory();
     configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer));
     
     SimpleLayout l = new SimpleLayout("xx${throwsException}yy", configurationItemFactory);
     string output = l.Render(LogEventInfo.CreateNullEvent());
     Assert.AreEqual("xxyy", output);
 }
        protected override void Append(StringBuilder builder, LogEventInfo logEvent)
        {
            if (!_isCached)
            {
                _cachedValue = GetValue();
            }

            var layout = new SimpleLayout(_cachedValue);
            builder.Append(layout.Render(logEvent));
        }
Exemplo n.º 4
0
        private static void Start( string[ ] args )
        {
            //register object builder assembly
            string path = System.IO.Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "SpaceEngineers.ObjectBuilders.DLL" );
            VRage.Plugins.MyPlugins.RegisterGameObjectBuildersAssemblyFile( path );

            MyObjectBuilderType.RegisterAssemblies( );

            //Setup error handling for unmanaged exceptions
            AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode( UnhandledExceptionMode.CatchException );

            //AppDomain.CurrentDomain.ClearEventInvocations("_unhandledException");

            BaseLog.Info( "Starting SEServerExtender with {0} arguments: {1}", args.Length, string.Join( "\r\n\t", args ) );

            CommandLineArgs extenderArgs = CommandLineArgs = new CommandLineArgs
                              {
                                  ConsoleTitle = string.Empty,
                                  AutoStart = false,
                                  WorldName = string.Empty,
                                  InstanceName = string.Empty,
                                  NoGui = false,
                                  NoConsole = false,
                                  Debug = false,
                                  GamePath = new DirectoryInfo( PathManager.BasePath ).Parent.FullName,
                                  NoWcf = false,
                                  Autosave = 0,
                                  InstancePath = string.Empty,
                                  CloseOnCrash = false,
                                  RestartOnCrash = false,
                                  Args = string.Join( " ", args.Select( x => string.Format( "\"{0}\"", x ) ) )
                              };

            if ( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryAge" ] != null )
                if ( !int.TryParse( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryAge" ], out _maxChatHistoryMessageAge ) )
                {
                    ConfigurationManager.AppSettings.Add( "WCFChatMaxMessageHistoryAge", "3600" );
                }
            if ( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryCount" ] != null )
                if ( !int.TryParse( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryCount" ], out _maxChatHistoryMessageCount ) )
                {
                    ConfigurationManager.AppSettings.Add( "WCFChatMaxMessageHistoryCount", "100" );
                }

            bool logPathSet = false;
            //Process the args
            foreach ( string arg in args )
            {
                string[ ] splitAtEquals = arg.Split( '=' );
                if ( splitAtEquals.Length > 1 )
                {
                    string argName = splitAtEquals[ 0 ];
                    string argValue = splitAtEquals[ 1 ];

                    string lowerCaseArgument = argName.ToLower( );
                    if ( lowerCaseArgument.Equals( "instance" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.InstanceName = argValue;

                        //Only let this override log path if the log path wasn't already explicitly set
                        if ( !logPathSet )
                        {
                            FileTarget baseLogTarget = LogManager.Configuration.FindTargetByName( "BaseLog" ) as FileTarget;
                            if ( baseLogTarget != null )
                            {
                                baseLogTarget.FileName = baseLogTarget.FileName.Render( new LogEventInfo { TimeStamp = DateTime.Now } ).Replace( "NoInstance", argValue );
                            }
                            FileTarget chatLogTarget = LogManager.Configuration.FindTargetByName( "ChatLog" ) as FileTarget;
                            if ( chatLogTarget != null )
                            {
                                chatLogTarget.FileName = chatLogTarget.FileName.Render( new LogEventInfo { TimeStamp = DateTime.Now } ).Replace( "NoInstance", argValue );
                            }
                            FileTarget pluginLogTarget = LogManager.Configuration.FindTargetByName( "PluginLog" ) as FileTarget;
                            if ( pluginLogTarget != null )
                            {
                                pluginLogTarget.FileName = pluginLogTarget.FileName.Render( new LogEventInfo { TimeStamp = DateTime.Now } ).Replace( "NoInstance", argValue );
                            }
                        }
                    }
                    else if ( lowerCaseArgument.Equals( "gamepath" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.GamePath = argValue;
                    }
                    else if ( lowerCaseArgument.Equals( "autosave" ) )
                    {
                        if ( !int.TryParse( argValue, out extenderArgs.Autosave ) )
                            BaseLog.Warn( "Autosave parameter was not a valid integer." );
                    }
                    else if ( lowerCaseArgument.Equals( "path" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.InstancePath = argValue;
                    }
                    else if ( lowerCaseArgument.Equals( "instancepath" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.InstancePath = argValue;
                    }
                    else if (lowerCaseArgument.Equals("title") )
                    {
                        if (argValue[argValue.Length - 1] == '"')
                            argValue = argValue.Substring(1, argValue.Length - 2);
                        extenderArgs.ConsoleTitle = argValue;
                    }
                    else if ( lowerCaseArgument == "logpath" )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );

                        //This argument always prevails.
                        FileTarget baseLogTarget = LogManager.Configuration.FindTargetByName( "BaseLog" ) as FileTarget;
                        if ( baseLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "SEServerExtenderLog-${shortdate}.log" ) );
                            baseLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            ApplicationLog.BaseLog = BaseLog;
                        }
                        FileTarget chatLogTarget = LogManager.Configuration.FindTargetByName( "ChatLog" ) as FileTarget;
                        if ( chatLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "ChatLog-${shortdate}.log" ) );
                            chatLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            ApplicationLog.ChatLog = ChatLog;
                        }
                        FileTarget pluginLogTarget = LogManager.Configuration.FindTargetByName( "PluginLog" ) as FileTarget;
                        if ( pluginLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "PluginLog-${shortdate}.log" ) );
                            pluginLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            logPathSet = true;
                            ApplicationLog.PluginLog = PluginLog;
                        }

                    }
                }
                else
                {
                    string lowerCaseArgument = arg.ToLower( );
                    if ( lowerCaseArgument.Equals( "autostart" ) )
                    {
                        extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "nogui" ) )
                    {
                        extenderArgs.NoGui = true;

                        //Implies autostart
                        //extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "noconsole" ) )
                    {
                        extenderArgs.NoConsole = true;

                        //Implies nogui and autostart
                        extenderArgs.NoGui = true;
                        extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "debug" ) )
                    {
                        extenderArgs.Debug = true;
                    }
                    else if ( lowerCaseArgument.Equals( "nowcf" ) )
                    {
                        extenderArgs.NoWcf = true;
                    }
                    else if ( lowerCaseArgument.Equals( "closeoncrash" ) )
                    {
                        extenderArgs.CloseOnCrash = true;
                    }
                    else if ( lowerCaseArgument.Equals( "autosaveasync" ) )
                    {
                        extenderArgs.AutoSaveSync = false;
                    }
                    else if ( lowerCaseArgument.Equals( "autosavesync" ) )
                    {
                        extenderArgs.AutoSaveSync = true;
                    }
                    else if ( lowerCaseArgument.Equals( "restartoncrash" ) )
                    {
                        extenderArgs.RestartOnCrash = true;
                    }
                    else if ( lowerCaseArgument.Equals( "wrr" ) )
                    {
                        extenderArgs.WorldRequestReplace = true;
                    }
                    else if ( lowerCaseArgument.Equals( "wrm" ) )
                    {
                        extenderArgs.WorldDataModify = true;
                    }
                    else if (lowerCaseArgument.Equals("wvm"))
                    {
                        extenderArgs.WorldVoxelModify = true;
                    }
                }
            }

            if ( !Environment.UserInteractive )
            {
                extenderArgs.NoConsole = true;
                extenderArgs.NoGui = true;
                extenderArgs.AutoStart = true;
            }

            if ( extenderArgs.Debug )
                ExtenderOptions.IsDebugging = true;

            try
            {
                bool unitTestResult = BasicUnitTestManager.Instance.Run( );
                if ( !unitTestResult )
                    ExtenderOptions.IsInSafeMode = true;

                Server = Server.Instance;
                Server.CommandLineArgs = extenderArgs;
                Server.IsWCFEnabled = !extenderArgs.NoWcf;
                Server.Init( );

                ChatManager.ChatCommand guiCommand = new ChatManager.ChatCommand( "gui", ChatCommand_GUI, false );
                ChatManager.Instance.RegisterChatCommand( guiCommand );

                if (string.IsNullOrEmpty (extenderArgs.ConsoleTitle) || string.IsNullOrWhiteSpace(extenderArgs.ConsoleTitle))
                {
                    Console.Title = "SESE";
                }
                else
                {
                    Console.Title = extenderArgs.ConsoleTitle;
                }

                if ( extenderArgs.AutoStart )
                {
                    Server.StartServer( );
                }

                if ( !extenderArgs.NoWcf )
                {
                    string uriString = string.Format( "{0}{1}", ConfigurationManager.AppSettings[ "WCFServerServiceBaseAddress" ], CommandLineArgs.InstanceName );
                    BaseLog.Info( "Opening up WCF service listener at {0}", uriString );
                    ServerServiceHost = new ServiceHost( typeof( ServerService.ServerService ), new Uri( uriString, UriKind.Absolute ) );
                    ServerServiceHost.Open( );
                    ChatManager.Instance.ChatMessage += ChatManager_ChatMessage;
                }

                if ( !extenderArgs.NoGui )
                {
                    Thread uiThread = new Thread( StartGui );
                    uiThread.SetApartmentState( ApartmentState.STA );
                    uiThread.Start( );
                }
                else if ( Environment.UserInteractive )
                    Console.ReadLine( );

            }
            catch ( AutoException eEx )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( "AutoException - {0}\n\r{1}", eEx.AdditionnalInfo, eEx.GetDebugString( ) );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( string.Format( "{0}\n\r{1}", eEx.AdditionnalInfo, eEx.GetDebugString( ) ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw eEx.GetBaseException( );
            }
            catch ( TargetInvocationException ex )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( "TargetInvocationException - {0}\n\r{1}", ex, ex.InnerException );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( string.Format( "{0}\n\r{1}", ex, ex.InnerException ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw;
            }
            catch ( Exception ex )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( ex, "Exception - {0}", ex );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( ex.ToString( ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Evaluates the specified text by expadinging all layout renderers.
 /// </summary>
 /// <param name="text">The text to be evaluated.</param>
 /// <param name="logEvent">Log event to be used for evaluation.</param>
 /// <returns>The input text with all occurences of ${} replaced with
 /// values provided by the appropriate layout renderers.</returns>
 public static string Evaluate(string text, LogEventInfo logEvent)
 {
     var l = new SimpleLayout(text);
     return l.Render(logEvent);
 }
Exemplo n.º 6
0
        public void LayoutRendererThrows2()
        {
            string internalLogOutput = RunAndCaptureInternalLog(
                () => 
                    {
                        ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory();
                        configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer));

                        SimpleLayout l = new SimpleLayout("xx${throwsException:msg1}yy${throwsException:msg2}zz", configurationItemFactory);
                        string output = l.Render(LogEventInfo.CreateNullEvent());
                        Assert.AreEqual("xxyyzz", output);
                    }, 
                    LogLevel.Warn);

            Assert.IsTrue(internalLogOutput.IndexOf("msg1") >= 0, internalLogOutput);
            Assert.IsTrue(internalLogOutput.IndexOf("msg2") >= 0, internalLogOutput);
        }
Exemplo n.º 7
0
        public void LayoutRendererThrows()
        {
            NLogFactories nlogFactories = new NLogFactories();
            nlogFactories.LayoutRendererFactory.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer));

            SimpleLayout l = new SimpleLayout("xx${throwsException}yy", nlogFactories);
            string output = l.Render(LogEventInfo.CreateNullEvent());
            Assert.AreEqual("xxyy", output);
        }
Exemplo n.º 8
0
        private static void Start( string[ ] args )
        {
            // SE_VERSION is a private constant. Need to use reflection to get it.
            FieldInfo field = typeof(SpaceEngineersGame).GetField("SE_VERSION", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

            SeVersion = new Version(new MyVersion((int)field.GetValue(null)).FormattedText.ToString().Replace("_", "."));

            bool stableBuild = (bool)typeof(MyFinalBuildConstants).GetField("IS_STABLE").GetValue(null);

            ApplicationLog.BaseLog.Info($"SE version: {SeVersion}");
            ApplicationLog.BaseLog.Info( $"Extender version: {Assembly.GetExecutingAssembly().GetName().Version}" );
            if (stableBuild)
            {
                BaseLog.Info("Detected \"Stable\" branch!");
                IsStable = true;
                PluginManager.IsStable = true;

                //hide the block limit config, since it will crash in stable
                HideConfigs();
            }
            else
                BaseLog.Info("Detected \"Development\" branch!");

            InitSandbox(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + @"..\Content"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineers"));

            //Setup error handling for unmanaged exceptions
            AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode( UnhandledExceptionMode.CatchException );

            //AppDomain.CurrentDomain.ClearEventInvocations("_unhandledException");

            BaseLog.Info( "Starting SEServerExtender with {0} arguments: {1}", args.Length, string.Join( "\r\n\t", args ) );

            CommandLineArgs extenderArgs = CommandLineArgs = new CommandLineArgs
                              {
                                  ConsoleTitle = string.Empty,
                                  AutoStart = false,
                                  WorldName = string.Empty,
                                  InstanceName = string.Empty,
                                  NoGui = false,
                                  NoConsole = false,
                                  Debug = false,
                                  GamePath = new DirectoryInfo( PathManager.BasePath ).Parent.FullName,
                                  //TODO: turn noWFC back to off by default whenever WCF gets fixed
                                  NoWcf = true,
                                  Autosave = 0,
                                  InstancePath = string.Empty,
                                  CloseOnCrash = false,
                                  RestartOnCrash = false,
                                  NoProfiler = false,
                                  Args = string.Join( " ", args.Select( x => string.Format( "\"{0}\"", x ) ) )
                              };

            if ( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryAge" ] != null )
                if ( !int.TryParse( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryAge" ], out _maxChatHistoryMessageAge ) )
                {
                    ConfigurationManager.AppSettings.Add( "WCFChatMaxMessageHistoryAge", "3600" );
                }
            if ( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryCount" ] != null )
                if ( !int.TryParse( ConfigurationManager.AppSettings[ "WCFChatMaxMessageHistoryCount" ], out _maxChatHistoryMessageCount ) )
                {
                    ConfigurationManager.AppSettings.Add( "WCFChatMaxMessageHistoryCount", "100" );
                }

            bool logPathSet = false;
            //Process the args
            foreach ( string arg in args )
            {
                string[ ] splitAtEquals = arg.Split( '=' );
                if ( splitAtEquals.Length > 1 )
                {
                    string argName = splitAtEquals[ 0 ];
                    string argValue = splitAtEquals[ 1 ];

                    string lowerCaseArgument = argName.ToLower( );
                    if ( lowerCaseArgument.Equals( "instance" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        //sanitize input because stupid people put full paths for this argument
                        extenderArgs.InstanceName = argValue.Replace( @"\", "-" ).Replace( @":", "-" );

                        //Only let this override log path if the log path wasn't already explicitly set
                        if ( !logPathSet )
                        {
                            FileTarget baseLogTarget = LogManager.Configuration.FindTargetByName( "BaseLog" ) as FileTarget;
                            if ( baseLogTarget != null )
                            {
                                baseLogTarget.FileName = baseLogTarget.FileName.Render(new LogEventInfo { TimeStamp = DateTime.Now }).Replace("NoInstance", argValue.Replace(@"\", "-").Replace(@":", "-"));
                            }
                            FileTarget chatLogTarget = LogManager.Configuration.FindTargetByName( "ChatLog" ) as FileTarget;
                            if ( chatLogTarget != null )
                            {
                                chatLogTarget.FileName = chatLogTarget.FileName.Render(new LogEventInfo { TimeStamp = DateTime.Now }).Replace("NoInstance", argValue.Replace(@"\", "-").Replace(@":", "-"));
                            }
                            FileTarget pluginLogTarget = LogManager.Configuration.FindTargetByName( "PluginLog" ) as FileTarget;
                            if ( pluginLogTarget != null )
                            {
                                pluginLogTarget.FileName = pluginLogTarget.FileName.Render(new LogEventInfo { TimeStamp = DateTime.Now }).Replace("NoInstance", argValue.Replace(@"\", "-").Replace(@":", "-"));
                            }
                        }
                    }
                    else if ( lowerCaseArgument.Equals( "gamepath" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.GamePath = argValue;
                    }
                    else if ( lowerCaseArgument.Equals( "autosave" ) )
                    {
                        if ( !int.TryParse( argValue, out extenderArgs.Autosave ) )
                            BaseLog.Warn( "Autosave parameter was not a valid integer." );
                    }
                    else if ( lowerCaseArgument.Equals( "path" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.InstancePath = argValue;
                    }
                    else if ( lowerCaseArgument.Equals( "instancepath" ) )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );
                        extenderArgs.InstancePath = argValue;
                    }
                    else if (lowerCaseArgument.Equals("title") )
                    {
                        if (argValue[argValue.Length - 1] == '"')
                            argValue = argValue.Substring(1, argValue.Length - 2);
                        extenderArgs.ConsoleTitle = argValue;
                    }
                    else if ( lowerCaseArgument == "logpath" )
                    {
                        if ( argValue[ argValue.Length - 1 ] == '"' )
                            argValue = argValue.Substring( 1, argValue.Length - 2 );

                        //This argument always prevails.
                        FileTarget baseLogTarget = LogManager.Configuration.FindTargetByName( "BaseLog" ) as FileTarget;
                        if ( baseLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "SEServerExtenderLog-${shortdate}.log" ) );
                            baseLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            ApplicationLog.BaseLog = BaseLog;
                        }
                        FileTarget chatLogTarget = LogManager.Configuration.FindTargetByName( "ChatLog" ) as FileTarget;
                        if ( chatLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "ChatLog-${shortdate}.log" ) );
                            chatLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            ApplicationLog.ChatLog = ChatLog;
                        }
                        FileTarget pluginLogTarget = LogManager.Configuration.FindTargetByName( "PluginLog" ) as FileTarget;
                        if ( pluginLogTarget != null )
                        {
                            Layout l = new SimpleLayout( Path.Combine( argValue, "PluginLog-${shortdate}.log" ) );
                            pluginLogTarget.FileName = l.Render( new LogEventInfo { TimeStamp = DateTime.Now } );
                            logPathSet = true;
                            ApplicationLog.PluginLog = PluginLog;
                        }

                    }
                }
                else
                {
                    string lowerCaseArgument = arg.ToLower( );
                    if ( lowerCaseArgument.Equals( "autostart" ) )
                    {
                        extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "nogui" ) )
                    {
                        extenderArgs.NoGui = true;

                        //Implies autostart
                        //extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "noconsole" ) )
                    {
                        extenderArgs.NoConsole = true;

                        //Implies nogui and autostart
                        extenderArgs.NoGui = true;
                        extenderArgs.AutoStart = true;
                    }
                    else if ( lowerCaseArgument.Equals( "debug" ) )
                    {
                        extenderArgs.Debug = true;
                    }
                    else if ( lowerCaseArgument.Equals( "nowcf" ) )
                    {
                        extenderArgs.NoWcf = true;
                    }
                    else if ( lowerCaseArgument.Equals( "wcfon" ) )
                    {
                        extenderArgs.NoWcf = false;
                    }
                    else if ( lowerCaseArgument.Equals( "closeoncrash" ) )
                    {
                        extenderArgs.CloseOnCrash = true;
                    }
                    else if ( lowerCaseArgument.Equals( "autosaveasync" ) )
                    {
                        extenderArgs.AutoSaveSync = false;
                    }
                    else if ( lowerCaseArgument.Equals( "autosavesync" ) )
                    {
                        extenderArgs.AutoSaveSync = true;
                    }
                    else if ( lowerCaseArgument.Equals( "restartoncrash" ) )
                    {
                        extenderArgs.RestartOnCrash = true;
                    }
                    else if (lowerCaseArgument.Equals("noprofiler") && !IsStable)
                    {
                        extenderArgs.NoProfiler = true;
                        Server.DisableProfiler = true;
                    }
                    //these things are legacy and don't work anyway
                    /*
                    else if ( lowerCaseArgument.Equals( "wrr" ) )
                    {
                        extenderArgs.WorldRequestReplace = true;
                    }
                    else if ( lowerCaseArgument.Equals( "wrm" ) )
                    {
                        extenderArgs.WorldDataModify = true;
                    }
                    else if (lowerCaseArgument.Equals("wvm"))
                    {
                        extenderArgs.WorldVoxelModify = true;
                    }
                    */
                }
            }

            if ( !Environment.UserInteractive )
            {
                extenderArgs.NoConsole = true;
                extenderArgs.NoGui = true;
                extenderArgs.AutoStart = true;
            }

            if ( extenderArgs.Debug )
                ExtenderOptions.IsDebugging = true;

            try
            {
                bool unitTestResult = BasicUnitTestManager.Instance.Run( );
                if ( !unitTestResult )
                    ExtenderOptions.IsInSafeMode = true;

                Server = Server.Instance;
                Server.CommandLineArgs = extenderArgs;
                Server.IsWCFEnabled = !extenderArgs.NoWcf;
                Server.Init( );

                //if(!DedicatedServerAssemblyWrapper.IsStable)
                //    InitSandbox(Path.Combine( GameInstallationInfo.GamePath, @"..\Content"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineers"));

                ChatManager.ChatCommand guiCommand = new ChatManager.ChatCommand( "gui", ChatCommand_GUI, false );
                ChatManager.Instance.RegisterChatCommand( guiCommand );

                if (!CommandLineArgs.NoConsole)
                {
                    if (string.IsNullOrEmpty(extenderArgs.ConsoleTitle) || string.IsNullOrWhiteSpace(extenderArgs.ConsoleTitle))
                    {
                        Console.Title = "SESE";
                    }
                    else
                    {
                        Console.Title = extenderArgs.ConsoleTitle;
                    }
                }

                if ( extenderArgs.AutoStart )
                {
                    Server.StartServer( );
                }

                if ( !extenderArgs.NoWcf )
                {
                    string uriString = string.Format( "{0}{1}", ConfigurationManager.AppSettings[ "WCFServerServiceBaseAddress" ], CommandLineArgs.InstanceName );
                    BaseLog.Info( "Opening up WCF service listener at {0}", uriString );
                    ServerServiceHost = new ServiceHost( typeof( ServerService.ServerService ), new Uri( uriString, UriKind.Absolute ) );
                    ServerServiceHost.Open( );
                    ChatManager.Instance.ChatMessage += ChatManager_ChatMessage;
                }

                if ( !extenderArgs.NoGui )
                {
                    Thread uiThread = new Thread( StartGui );
                    uiThread.SetApartmentState( ApartmentState.STA );
                    uiThread.Start( );
                }
                else if ( Environment.UserInteractive )
                    Console.ReadLine( );

            }
            catch ( AutoException eEx )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( "AutoException - {0}\n\r{1}", eEx.AdditionnalInfo, eEx.GetDebugString( ) );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( string.Format( "{0}\n\r{1}", eEx.AdditionnalInfo, eEx.GetDebugString( ) ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw eEx.GetBaseException( );
            }
            catch ( TargetInvocationException ex )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( "TargetInvocationException - {0}\n\r{1}", ex, ex.InnerException );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( string.Format( "{0}\n\r{1}", ex, ex.InnerException ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw;
            }
            catch ( Exception ex )
            {
                if ( !extenderArgs.NoConsole )
                    BaseLog.Info( ex, "Exception - {0}", ex );
                if ( !extenderArgs.NoGui )
                    MessageBox.Show( ex.ToString( ), @"SEServerExtender", MessageBoxButtons.OK, MessageBoxIcon.Error );

                if ( extenderArgs.NoConsole && extenderArgs.NoGui )
                    throw;
            }
        }