TG.WXCRM.V4/WX.CRM.DataSynServer/Socket/SocketServiceManage.cs

51 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using SuperSocket.SocketBase;
using SuperSocket.SocketEngine;
using System;
using System.IO;
using WX.CRM.Common;
namespace WX.CRM.DataSynServer.Socket
{
public class SocketServiceManage
{
private static IBootstrap IBootstrap { get; set; }
private static readonly string LogServiceConfigFileName = Config.LogServiceConfigFileName;
public static bool Start()
{
try
{
var configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LogServiceConfigFileName);
IBootstrap = BootstrapFactory.CreateBootstrapFromConfigFile(configFilePath);
if (!IBootstrap.Initialize())
{
Console.WriteLine("日志服务初始化失败");
LogHelper.Error("日志服务启动失败!");
return false;
}
var result = IBootstrap.Start();
if (result == StartResult.Failed)
{
Console.WriteLine("日志服务启动失败!");
LogHelper.Error("日志服务启动失败!");
return false;
}
LogHelper.Info("Socket服务启动成功");
return true;
}
catch (Exception ex)
{
LogHelper.Error($"启动日志Socket服务失败:{ex}");
return false;
}
}
public static void Stop()
{
if (IBootstrap != null)
IBootstrap.Stop();
IBootstrap = null;
}
}
}