Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            message = null;

            message = "Loading...";

            Console.Title = message;

            XmlConfigurator.ConfigureAndWatch(new FileInfo("_appengine.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Database = new Database())
            {
                GameData = new EmbeddedData();

                autoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART;

                InstanceId = Guid.NewGuid().ToString();

                var port = Settings.IS_PRODUCTION ? Settings.APPENGINE.PRODUCTION_PORT : Settings.APPENGINE.TESTING_PORT;

                while (!PortCheck(port))
                {
                    ForceShutdown(port);
                }

                listener = new HttpListener();
                listener.Prefixes.Add(string.Format("http://{1}:{0}/", port, Settings.IS_PRODUCTION ? "*" : "localhost"));
                listener.Start();

                listener.BeginGetContext(ListenerCallback, null);
                Console.CancelKeyPress += (sender, e) => e.Cancel = true;

                if (autoRestart)
                {
                    restart();
                }

                Console.Title = Settings.APPENGINE.TITLE;

                ISManager manager = new ISManager();
                manager.Run();

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                while (currentRequests.Count > 0)
                {
                    ;
                }

                manager.Dispose();
                listener?.Stop();
                GameData.Dispose();

                Environment.Exit(0);
            }
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Console.Title = "Loading...";

            XmlConfigurator.ConfigureAndWatch(new FileInfo("_appengine.config"));

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.Name           = "Entry";

            using (Database = new Database())
            {
                GameData = new EmbeddedData();

                autoRestart = Settings.NETWORKING.RESTART.ENABLE_RESTART;

                InstanceId = Guid.NewGuid().ToString();

                var port = Settings.IS_PRODUCTION ? Settings.APPENGINE.PRODUCTION_PORT : Settings.APPENGINE.TESTING_PORT;

                while (!PortCheck(port))
                {
                    ForceShutdown(port);
                }

                listener = new HttpListener();
                listener.Prefixes.Add(string.Format("http://{1}:{0}/", port, Settings.IS_PRODUCTION ? "*" : "localhost"));
                listener.Start();

                listener.BeginGetContext(ListenerCallback, null);
                Console.CancelKeyPress += (sender, e) => e.Cancel = true;
                Logger.Info("Listening at port " + port + "...");

                if (autoRestart)
                {
                    delay  = Settings.NETWORKING.RESTART.RESTART_DELAY_MINUTES;
                    sw     = Stopwatch.StartNew();
                    delay_ = 0;
                    new Thread(restart).Start();
                    new Thread(uptime).Start();
                }

                UpdateTitle(autoRestart, TimeSpan.MinValue);

                ISManager manager = new ISManager();
                manager?.Run();

                while (Console.ReadKey(true).Key != ConsoleKey.Escape)
                {
                    ;
                }

                Logger.Info("Terminating...");
                while (currentRequests.Count > 0)
                {
                    ;
                }
                manager?.Dispose();
                listener?.Stop();
                GameData?.Dispose();
                Logger.Info("AppEngine terminated.");
                Environment.Exit(0);
            }
        }