示例#1
0
        public static int Main(string[] args)
        {
            Console.WriteLine("ObjectServer Development Server\n");

            try
            {
                var cfg = InitializeFramework(args);
                AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnExit);

                using (var server = new HttpServer(cfg.HttpListenUrl))
                {
                    server.Start(WaitToQuit);
                    Console.WriteLine("Starting to broadcast the TERMINATE command...");
                    Console.WriteLine("Terminating...");
                }

                return(0);
            }
            catch (OptionException ex)
            {
                Console.WriteLine("Bad argument(s): ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try `slipserver.exe --help' for more information.");
                return(-1);
            }
            catch (Exception ex)
            {
                LoggerProvider.EnvironmentLogger.ErrorException(
                    "Unhandled Exception: " + ex.Message, ex);
                var oldColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Unhandled exception:\n{0}", ex.Message);
                Console.ForegroundColor = oldColor;
                return(-1);
            }
            finally
            {
                SlipstreamEnvironment.Shutdown();
            }
        }
示例#2
0
        public static int Main(string[] args)
        {
            Console.WriteLine("ObjectServer Development Server\n");

            try
            {
                InitializeFramework(args);
                AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnExit);

                using (var server = new ServerProcess())
                {
                    var serverThreadProc = new ThreadStart(delegate
                    {
                        server.Run();
                    });

                    var serverThread = new Thread(serverThreadProc);
                    serverThread.Start();

                    Console.WriteLine("Waiting for client requests...");
                    WaitToQuit();

                    Console.WriteLine("Starting to broadcast the TERMINATE command...");
                    var role = SlipstreamEnvironment.Settings.Role;
                    if (role == ServerRoles.Standalone || role == ServerRoles.Controller)
                    {
                        server.BeginStopAll();
                    }
                    else if (role == ServerRoles.HttpServer)
                    {
                        server.BeginStopHttpServer();
                    }
                    else if (role == ServerRoles.Worker)
                    {
                        server.BeginStopRpcWorkers();
                    }

                    Console.WriteLine("Terminating...");
                }

                return(0);
            }
            catch (OptionException ex)
            {
                Console.WriteLine("Bad argument(s): ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try `slipserver.exe --help' for more information.");
                return(-1);
            }
            catch (Exception ex)
            {
                LoggerProvider.EnvironmentLogger.ErrorException(
                    "Unhandled Exception: " + ex.Message, ex);
                var oldColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Unhandled exception:\n{0}", ex.Message);
                Console.ForegroundColor = oldColor;
                return(-1);
            }
            finally
            {
                SlipstreamEnvironment.Shutdown();
            }
        }