예제 #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"));
        }