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); }
internal static async Task <int> RunMain(string[] arguments) { SetWorkingDirectory(); const int Result = 0; if (Environment.UserInteractive || (arguments.Any() && arguments[0] == "--interactive")) { Dev2Logger.Info("** Starting In Interactive Mode **", GlobalConstants.WarewolfInfo); var manager = new ServerLifecycleManager(new ServerEnvironmentPreparer()); var runTask = manager.Run(new LifeCycleInitializationList()); runTask.Wait(); WaitForUserExit(manager); } else { Dev2Logger.Info("** Starting In Service Mode **", GlobalConstants.WarewolfInfo); using (var service = new ServerLifecycleManagerService()) { ServiceBase.Run(service); if (!service.RunSuccessful) { Dev2Logger.Warn("** Service Mode Failed to Start **", GlobalConstants.WarewolfWarn); return(-1); } } } return(Result); }
internal static async Task <int> RunMain(string[] arguments) { SetWorkingDirectory(); const int Result = 0; #if DEBUG if (Environment.GetEnvironmentVariable("WAREWOLF_SERVER_DEBUG") == "1") { Dev2Logger.Info("** Starting In Debugging Mode **", GlobalConstants.WarewolfInfo); while (!Debugger.IsAttached) { Thread.Sleep(3000); Console.WriteLine("Still waiting for remote debugging..."); } Console.WriteLine("Ready for remote debugging."); } #endif if (Environment.UserInteractive || (arguments.Any() && arguments[0] == "--interactive")) { Dev2Logger.Info("** Starting In Interactive Mode **", GlobalConstants.WarewolfInfo); var manager = new ServerLifecycleManager(new ServerEnvironmentPreparer()); var runTask = manager.Run(new LifeCycleInitializationList()); runTask.Wait(); WaitForUserExit(manager); } else { Dev2Logger.Info("** Starting In Service Mode **", GlobalConstants.WarewolfInfo); using (var service = new ServerLifecycleManagerService()) { ServiceBase.Run(service); if (!service.RunSuccessful) { Dev2Logger.Warn("** Service Mode Failed to Start **", GlobalConstants.WarewolfWarn); return(-1); } } } return(Result); }