Пример #1
0
        static void Main(string[] args)
        {
            string ip   = IpHelper.InternetIp4();
            int    port = GetPort(ip);

            var isRegsiterToRegiserCenter = StringHelper.ToInt32(ConfigurationManager.AppSettings["isRegsiterToRegiserCenter"], 1);

            if (isRegsiterToRegiserCenter == 1)
            {
                string registerUrl = ConfigurationManager.AppSettings["registerUrl"];
                string redisUrl    = ConfigurationManager.AppSettings["redisUrl"];
                var    builder     = new RedisDirectoryBuilder(registerUrl, redisUrl);
                builder.Build(new MySelfInfo()
                {
                    Description = "Demo子服务",
                    Directory   = "ServiceDemo",
                    Status      = 1,
                    Weight      = 10,
                    Url         = string.Format("http://{0}:{1}/api/", ip, port),
                    Ip          = ip + ":" + port
                }, new string[] { }, new string[]
                {
                    "Demo/SayHello",
                    "Demo/GetStudentInfo",
                    "Home/Index"
                });

                string monitorUrl = ConfigurationManager.AppSettings["monitorUrl"];
                MonitorManager.RegisterSend(new HttpSendCollectorData(monitorUrl));
            }



            string baseUrl = string.Format("http://{0}:{1}/", ip, port);

            using (WebApp.Start <Startup>(new StartOptions(baseUrl)))
            {
                System.Console.WriteLine("服务启动中...");
                while (true)
                {
                    Thread.Sleep(80000012);
                }
            }
        }
Пример #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            DirectoryFactory.Register("EasyDemo", new StaticDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "servicedemo.config"), "EasyDemo"));


            var isRegsiterToRegiserCenter = StringHelper.ToInt32(ConfigurationManager.AppSettings["isRegsiterToRegiserCenter"], 1);

            if (isRegsiterToRegiserCenter == 1)
            {
                string registerUrl   = ConfigurationManager.AppSettings["registerUrl"];
                string redisUrl      = ConfigurationManager.AppSettings["redisUrl"];
                int    databaseIndex = int.Parse(ConfigurationManager.AppSettings["databaseIndex"]);
                var    builder       = new RedisDirectoryBuilder(registerUrl, redisUrl);
                builder.Build(new MySelfInfo()
                {
                    Description = "Demo站点",
                    Directory   = "DemoWebSite",
                    Status      = 1,
                    Weight      = 10,
                    Url         = string.Format("http://{0}", IpHelper.InternetIp4()),
                    Ip          = string.Format("{0}:{1}", IpHelper.InternetIp4(), 80)
                }, new string[1] {
                    "ServiceDemo"
                }, new string[0]);

                string monitorUrl = ConfigurationManager.AppSettings["monitorUrl"];
                MonitorManager.RegisterSend(new HttpSendCollectorData(monitorUrl));
            }
            //if (ConfigurationManager.AppSettings["remoteLog"] == "true")
            //{
            //    LogManager.Register(new RemoteLogger() { Url = "http://101.200.124.233:3100/logH5" });
            //}


            //string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EasyDemo.config");
            //Easy.Rpc.directory.DirectoryFactory.Register("EasyDemo", new StaticDirectory(path, "EasyDemo"));
        }
Пример #3
0
        static void Main(string[] args)
        {
            string ip   = IpHelper.IntranetIp4();
            int    port = GetPort(ip);
            var    isRegsiterToRegiserCenter = StringHelper.ToInt32(ConfigurationManager.AppSettings["isRegsiterToRegiserCenter"], 1);

            if (isRegsiterToRegiserCenter == 1)
            {
                string registerUrl   = ConfigurationManager.AppSettings["registerUrl"];
                string redisUrl      = ConfigurationManager.AppSettings["redisUrl"];
                int    databaseIndex = int.Parse(ConfigurationManager.AppSettings["databaseIndex"]);
                var    builder       = new RedisDirectoryBuilder(registerUrl, redisUrl, databaseIndex);
                builder.Build(new MySelfInfo()
                {
                    Description = "菜品服务",
                    Directory   = "StudyMenu",
                    Status      = 1,
                    Weight      = 10,
                    Url         = string.Format("http://{0}:{1}/api/", ip, port),
                    Ip          = ip + ":" + port
                }, new string[0], new string[] {
                    "Category/Add",
                    "Category/Select"
                });

                //// todo:注册到监控中心
            }

            //string baseUrl = ConfigurationManager.AppSettings["ServiceAddress"];
            string baseUrl = string.Format("http://{0}:{1}/", ip, port);

            Console.WriteLine(baseUrl);
            using (WebApp.Start <Startup>(new StartOptions(baseUrl)))
            {
                System.Console.WriteLine("服务启动中...");
                while (true)
                {
                    Thread.Sleep(80000012);
                }
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            string registerUrl        = ConfigurationManager.AppSettings["registerUrl"];
            string redisServer        = ConfigurationManager.AppSettings["redisServer"];
            int    redisDatabaseIndex = int.Parse(ConfigurationManager.AppSettings["redisDatabaseIndex"]);

            RedisDirectoryBuilder builder = new RedisDirectoryBuilder(registerUrl, redisServer, redisDatabaseIndex);

            var myselfInfo = new MySelfInfo()
            {
                Description = "ProviderAndConsumer提供者",
                Directory   = "ProviderAndConsumer",
                Ip          = "127.0.0.1:4008",
                Status      = 1,
                Url         = "http://127.0.0.1:4008",
                Weight      = 100
            };

            builder.Build(myselfInfo, new string[1] {
                "DemoProvider"
            });

            Console.ReadLine();
        }