protected override void OnStart(string[] args) { Logger.Info("准备启动服务!"); //创建RabbitMq队列连接 if (!RabbitMqServiceManage.Start()) { Logger.Info("连接RabbitMq队列失败!"); this.Stop(); return; } //启动日志落地服务 用于将日志从队列转移到Db manager.StartGetMsg(LogLevel.Info); manager.StartGetMsg(LogLevel.Error); //启动Socket服务 用户接收客户端消息 if (!SocketServiceManage.Start()) { Logger.Info("Socket服务启动失败!"); this.Stop(); return; } //启动WebApi服务 用户提供管理端接口 if (!WebApiServiceManage.SelfHostStart(ServiceAddress)) { Logger.Info("WebApi服务启动失败!"); this.Stop(); } }
static void Main(string[] args) { RabbitMqServiceManage.Start(); ILogMQServiceManager manager = new LogMQServiceManager(); manager.StartGetMsg(LogLevel.Info); Console.ReadLine(); }
protected void Application_Start() { Logger.Info("准备启动Web版服务!"); WebApiServiceManage.WebHostStart(); //启动通道 RabbitMqServiceManage.Start(); }
protected override void OnStop() { //终止队列连接 RabbitMqServiceManage.Stop(); //终止Socket服务 SocketServiceManage.Stop(); //终止WebApi服务 WebApiServiceManage.SelfHostStop(); }
static void Main(string[] args) { RabbitMqServiceManage.Start(); if (!SocketServiceManage.Start()) { Console.WriteLine("服务启动失败!"); } manager.StartGetMsg(LogLevel.Info); Console.ReadLine(); SocketServiceManage.Stop(); Console.WriteLine("The server was stopped!"); Console.ReadKey(); }
protected void Application_End() { WebApiServiceManage.WebHostStop(); //关闭通道 RabbitMqServiceManage.Stop(); }