Menu
🌜
🌞
- 1. 框架介绍
- 2. 注册中心
- 3. 服务Provider
- 4. 网关&监控
- 5. 服务资源监控
- 6. 集群接口文档
- 7. Hello World
- 8. 集成Java
- 9. 进阶指南
- 10. 领域驱动设计
- 11. 事件总线
- 12. 更多
- 13.1 好文章集合
using Anno.Rpc.Center;
using System;
namespace ViperCenter
{
class Program
{
/// <summary>
/// 注册中心只用增加一个 Anno.config配置文件,然后直接 Bootstrap.StartUp(args);启动即可
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Console.Title = "ViperCenter";
//服务变动钉钉通知
DingTalkNotify.CustomConfiguration.InitConst();
Bootstrap.StartUp(args
, (service, noticeType) =>//上线下线
{
DingTalkNotify.Notice(service,noticeType);
}, (newService, oldService) =>//服务配置更改
{
DingTalkNotify.ChangeNotice(newService, oldService);
});
}
}
}
### 2.1.2 配置文件#
配置文件 Anno.config
Port:为注册中心的监听端口
TimeOut:为注册中心默认连接超时时间单位毫秒
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!—#lbs 配置—>
<Port>7010</Port>
<TimeOut>120000</TimeOut>
<Servers>
</Servers>
</configuration>
### 2.1.3 启动注册中心#
配置完成后便可以启动注册中心
Windows
dotnet ViperCenter.dll
Linux
#!/bin/bash
if [ $1 == "start" ];then
nohup dotnet ViperCenter.dll 2>&1 &
echo "$!" > pid
echo "start ok!"
elif [ $1 == "stop" ];then
kill cat pid
echo "stop ok!"
else
echo "Please make sure the position variable is start or stop."
fi
看到如下画面代表运行成功
此时可以去启动ViperService,注册ViperService 到注册中心
Edit this page
Previous
« 1.3 项目源码结构
Next
3.1 服务提供者ViperService概述 »
- 2.1.1 一行代码的注册中心
- 2.1.2 配置文件
- 2.1.3 启动注册中心
文档
社区
更多
Copyright © 2022 Anno.

