-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
224 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/**************************************************************************** | ||
*项目名称:SAEA.WebRedisManager | ||
*CLR 版本:4.0.30319.42000 | ||
*机器名称:WALLE-PC | ||
*命名空间:SAEA.WebRedisManager | ||
*类 名 称:AppService | ||
*版 本 号:V1.0.0.0 | ||
*创建人: yswenli | ||
*电子邮箱:yswenli@outlook.com | ||
*修改时间:2021/7/8 18:24:22 | ||
*描述: | ||
*===================================================================== | ||
*修改时间:2021/7/8 18:24:22 | ||
*修 改 人: yswenli | ||
*版 本 号: V1.0.0.0 | ||
*描 述: | ||
*****************************************************************************/ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.Extensions.Hosting; | ||
|
||
using SAEA.Common; | ||
using SAEA.MVC; | ||
using SAEA.WebRedisManager.Libs; | ||
|
||
namespace SAEA.WebRedisManager | ||
{ | ||
public class AppService : BackgroundService | ||
{ | ||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
await Task.Yield(); | ||
|
||
var config = SAEAMvcApplicationConfigBuilder.Read(); | ||
|
||
config.Port = 16379; | ||
|
||
config.IsStaticsCached = false; | ||
|
||
SAEAMvcApplicationConfigBuilder.Write(config); | ||
|
||
//启动api | ||
|
||
SAEAMvcApplication mvcApplication = new SAEAMvcApplication(config); | ||
|
||
mvcApplication.Start(); | ||
|
||
//启动websocket | ||
|
||
WebSocketsHelper webSocketsHelper = new WebSocketsHelper(port: 16666); | ||
|
||
webSocketsHelper.Start(); | ||
|
||
ConsoleHelper.WriteLine("SAEA.WebRedisManager Already started"); | ||
|
||
ConsoleHelper.WriteLine($"Please open on Browser:http://127.0.0.1:{config.Port}/"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/**************************************************************************** | ||
*项目名称:SAEA.WebRedisManager.Libs | ||
*CLR 版本:4.0.30319.42000 | ||
*机器名称:WALLE-PC | ||
*命名空间:SAEA.WebRedisManager.Libs | ||
*类 名 称:WorkerServiceHelper | ||
*版 本 号:V1.0.0.0 | ||
*创建人: yswenli | ||
*电子邮箱:yswenli@outlook.com | ||
*修改时间:2021/7/8 18:24:22 | ||
*描述: | ||
*===================================================================== | ||
*修改时间:2021/7/8 18:24:22 | ||
*修 改 人: yswenli | ||
*版 本 号: V1.0.0.0 | ||
*描 述: | ||
*****************************************************************************/ | ||
using System.Runtime.InteropServices; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace SAEA.WebRedisManager.Libs | ||
{ | ||
public static class WorkerServiceHelper | ||
{ | ||
/// <summary> | ||
/// 创建传统类型的服务容器 | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public static IHostBuilder CreateHostBuilder<T>(string[] args) where T : class, IHostedService | ||
{ | ||
bool isWinPlantform = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | ||
|
||
if (isWinPlantform) | ||
{ | ||
return Host.CreateDefaultBuilder(args) | ||
.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddHostedService<T>(); | ||
}).UseWindowsService(); | ||
} | ||
else | ||
{ | ||
return Host.CreateDefaultBuilder(args) | ||
.UseSystemd() | ||
.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddHostedService<T>(); | ||
}); | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.