|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Topshelf;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.RealTimeService
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Main
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
MainService ms = new MainService(args);
|
|
|
|
|
ms.Start();
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
|
|
|
|
|
#region Topshelf——写入windows服务,需要开启
|
|
|
|
|
//var rc = HostFactory.Run(x =>
|
|
|
|
|
//{
|
|
|
|
|
// x.Service<MainService>(s =>
|
|
|
|
|
// {
|
|
|
|
|
// s.ConstructUsing(name => new MainService(args));
|
|
|
|
|
// s.WhenStarted(tc => tc.Start());
|
|
|
|
|
// s.WhenStopped(tc => tc.Stop());
|
|
|
|
|
// });
|
|
|
|
|
// x.RunAsLocalSystem();
|
|
|
|
|
|
|
|
|
|
// x.SetDescription("JwtAPIService");
|
|
|
|
|
// x.SetDisplayName("JwtAPIService");
|
|
|
|
|
// x.SetServiceName("JwtAPIService");
|
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
//var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode());
|
|
|
|
|
//Environment.ExitCode = exitCode;
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CreateHostBuilder
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//public static IHostBuilder CreateHostBuilder(string[] args)
|
|
|
|
|
//{
|
|
|
|
|
// //初始化默认主机Builder
|
|
|
|
|
// var hostBuilder = Host.CreateDefaultBuilder(args)
|
|
|
|
|
// //Autofac服务工厂
|
|
|
|
|
// .UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
|
|
|
// .ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
// {
|
|
|
|
|
// webBuilder.UseStartup<Startup>();
|
|
|
|
|
// })
|
|
|
|
|
// .ConfigureLogging((hostingContext, builder) =>
|
|
|
|
|
// {
|
|
|
|
|
// //清楚控制台log日志
|
|
|
|
|
// builder.ClearProviders();
|
|
|
|
|
// // 1.过滤掉系统默认的一些日志
|
|
|
|
|
// builder.AddFilter("System", LogLevel.Error);
|
|
|
|
|
// builder.AddFilter("Microsoft", LogLevel.Error);
|
|
|
|
|
|
|
|
|
|
// // 默认log4net.confg
|
|
|
|
|
// builder.AddLog4Net(Path.Combine(Directory.GetCurrentDirectory(), "Log4net.config"));
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// return hostBuilder;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|