Esempio n. 1
0
        static void Main(string[] args)
        {
            var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];

            using (var appHost = new AppSelfHost())
            {
                try
                {
                    appHost.Init();
                    appHost.Start(listeningOn);

                    Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn);
                    Console.WriteLine("Press <CTRL>+C to stop.");
                    Thread.Sleep(Timeout.Infinite);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR: {0}: {1}", ex.GetType().Name, ex.Message);
                    throw;
                }
                finally
                {
                    appHost.Stop();
                }
            }

            Console.WriteLine("AppHost has finished");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];

            using (var appHost = new AppSelfHost())
            {
                try
                {
                    appHost.Init();

                    // TODO: switch to Start after the next ServiceStack deployment (added to framework on commit #806)
                    appHost.StartListening(listeningOn);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR: {0}: {1}", ex.GetType().Name, ex.Message);
                }
                finally
                {
                    appHost.Stop();
                }
            }

            Console.WriteLine("AppHost has finished");
        }
Esempio n. 3
0
        private static void Main(string[] args)
        {
            var options = new ServerOptions
            {
                DispatcherPort   = Settings.Default.DispatcherPort,
                EndpointHostname = Settings.Default.EndpointHostname,
                EndpointPort     = Settings.Default.EndpointPort,
                LogPort          = Settings.Default.LogPort,
                AppPort          = Settings.Default.AppPort,
                ClientPort       = Settings.Default.ClientPort
            };
            LogListener  logHost      = new LogListener(options.LogPort, options.ClientPort);
            ApiSelfHost  apiHost      = new ApiSelfHost(options);
            AppSelfHost  appHost      = new AppSelfHost(options);
            JobScheduler jobScheduler = new JobScheduler();

            apiHost.Start();
            appHost.Start();
            logHost.Start();
            jobScheduler.Start();
            FixDebugListeners();
            string infoText = GetInfoText(options);
            bool   listen   = true;

            while (listen)
            {
                Console.Clear();
                Console.Write(infoText);
                foreach (var connection in logHost.GetConnectionList())
                {
                    string connectionState = connection.Connected ? "connected" : "disconnected";
                    Console.WriteLine("#{0} {1} {2} {3} {4}",
                                      connection.Id,
                                      connection.ClientId,
                                      connection.ClientName,
                                      connection.ClientComputerName,
                                      connectionState);
                }
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                {
                    listen = false;
                }
                Thread.Sleep(100);
            }
            jobScheduler.Stop();
            logHost.Stop();
            appHost.Stop();
            apiHost.Stop();
        }