Exemplo n.º 1
0
        private static void Main()
        {
            DHTServerCtx.DHT.MyPublicUrl = Environment.GetEnvironmentVariable("PUBLIC_URL");             //http://localhost:8888/

            if (string.IsNullOrWhiteSpace(DHTServerCtx.DHT.MyPublicUrl) || !Uri.IsWellFormedUriString(DHTServerCtx.DHT.MyPublicUrl, UriKind.RelativeOrAbsolute))
            {
                throw new MissingFieldException("PUBLIC_URL have to be set");
            }

            var parentServerUrl = Environment.GetEnvironmentVariable("PARENT_URL");             //http://localhost:8889/

            if (!string.IsNullOrWhiteSpace(parentServerUrl) && !Uri.IsWellFormedUriString(parentServerUrl, UriKind.RelativeOrAbsolute))
            {
                throw new FormatException("PARENT_URL have to be URL");
            }

            var appHost = new AppHost();

            appHost.Init();
            Console.WriteLine(DHTServerCtx.DHT.MyPublicUrl);
            appHost.Start(DHTServerCtx.DHT.MyPublicUrl);

            Console.WriteLine("AppHost Created at {0}, listening on {1}, parent server URL is {2}", DateTime.Now, DHTServerCtx.DHT.MyPublicUrl, parentServerUrl);
            joinDHT(parentServerUrl, DHTServerCtx.DHT.MyPublicUrl, appHost.Container);

            Console.Write(DHTServerCtx.DHT);
            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();

            Console.Write(DHTServerCtx.DHT);
            leaveDHT(appHost.Container);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length > 2)
            {
                Console.Error.WriteLine("Usage: server <port_number>");
                Environment.Exit(1);
            }
            ushort port = 8888;

            if (args.Length == 1 && !ushort.TryParse(args[0], out port))
            {
                Console.Error.WriteLine("Wrong port number");
                Environment.Exit(2);
            }

            var appHost = new AppHost();

            appHost.Init();
            var listeningOn = string.Format("http://*:{0}/", port);

            appHost.Start(listeningOn);

            new ManualResetEventSlim(false).Wait();

            appHost.Stop();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Error.WriteLine("Usage: server <listen_address>");
                Environment.Exit(1);
            }
            var addressPattern = new Regex(@"^(http|https)://.+(:d+)?/?$");
            var listenAddress  = string.Concat(args[0].TrimEnd(new char[] { '/' }), "/");

            if (!addressPattern.IsMatch(listenAddress))
            {
                Console.Error.WriteLine("Invalid address format");
                Environment.Exit(2);
            }

            var appHost = new AppHost(listenAddress);

            appHost.Init();
            appHost.Start(listenAddress);
            appHost.BeginRecovery();
            BeginHeartbeat(listenAddress);

            Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listenAddress);
            new System.Threading.ManualResetEventSlim(false).Wait();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            if (args.Length > 2)
            {
                Console.Error.WriteLine("Usage: server <port_number>");
                Environment.Exit(1);
            }
            ushort port = 8888;

            if (args.Length == 1 && !ushort.TryParse(args[0], out port))
            {
                Console.Error.WriteLine("Wrong port number");
                Environment.Exit(2);
            }

            var appHost = new AppHost();

            appHost.Init();
            var listeningOn = string.Format("http://*:{0}/", port);

            appHost.Start(listeningOn);

            Console.WriteLine("AppHost Created at {0}, listening on {1}", DateTime.Now, listeningOn);
            Console.WriteLine("Press <ENTER> key to exit...");
            Console.ReadLine();
            appHost.Stop();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];
            var appHost     = new AppHost();

            appHost.Init();
            appHost.Start(listeningOn);

            Console.WriteLine("AppHost Created at {0}, listening on {1}",
                              DateTime.Now, listeningOn);

            Console.ReadKey();
        }
Exemplo n.º 6
0
		private static void Main ()
		{/*
			var scheduler = new servstack.Scheduler ();
			scheduler.AddNode ("localhost", 15000);
			scheduler.AddNode ("localhost", 16000);
			scheduler.AddNode ("localhost", 17000);


			scheduler.AddJob (
				StringToByteArray ("900150983cd24fb0d6963f7d28e17f73"), Common.HashType.MD5, 4);
*/

			var appHost = new AppHost ();
			appHost.Init ();
			ushort port = 8888;
			string listeningOn = string.Format ("http://*:{0}/", port);
			appHost.Start (listeningOn);

			Console.WriteLine ("AppHost created at {0}, listening on {1}", DateTime.Now, listeningOn);
			Console.WriteLine ("Press ENTER to exit...");
			Console.ReadLine ();
		}