Compare commits
No commits in common. "039a1a8b891ae888af8991923b5806ea30901aba" and "9c24f53eb6ecf97683f446e4d95f138a3367d0f4" have entirely different histories.
039a1a8b89
...
9c24f53eb6
@ -24,6 +24,7 @@ namespace JiShe.CollectBus.Protocol.Contracts.Abstracts
|
|||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_protocolInfoRepository = serviceProvider.GetRequiredService<IRepository<ProtocolInfo, Guid>>();
|
_protocolInfoRepository = serviceProvider.GetRequiredService<IRepository<ProtocolInfo, Guid>>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
namespace JiShe.CollectBus.Host
|
namespace JiShe.CollectBus.Host
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// CollectBusHostConst
|
|
||||||
/// </summary>
|
|
||||||
public static class CollectBusHostConst
|
public static class CollectBusHostConst
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -26,15 +23,9 @@
|
|||||||
public const string HangfireDashboardEndPoint = "/hangfire";
|
public const string HangfireDashboardEndPoint = "/hangfire";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 健康检查 端点
|
/// CAP 端点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string HealthEndPoint = "/health";
|
public const string CapDashboardEndPoint = "/cap";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 健康检查 端点
|
|
||||||
/// </summary>
|
|
||||||
public const string HealthDashboardEndPoint = "/health-ui";
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Hangfire.Redis.StackExchange;
|
using Hangfire.Redis.StackExchange;
|
||||||
using JiShe.CollectBus.Host.Hangfire;
|
using JiShe.CollectBus.Host.Hangfire;
|
||||||
using JiShe.CollectBus.Host.HealthChecks;
|
|
||||||
using JiShe.CollectBus.Host.Swaggers;
|
using JiShe.CollectBus.Host.Swaggers;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
@ -17,9 +16,6 @@ using Volo.Abp.Modularity;
|
|||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using JiShe.CollectBus.Plugins;
|
using JiShe.CollectBus.Plugins;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
||||||
using JiShe.CollectBus.Cassandra;
|
|
||||||
|
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Host
|
namespace JiShe.CollectBus.Host
|
||||||
@ -210,6 +206,7 @@ namespace JiShe.CollectBus.Host
|
|||||||
private void ConfigureCustom(ServiceConfigurationContext context, IConfiguration configuration)
|
private void ConfigureCustom(ServiceConfigurationContext context, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
context.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
context.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
context.Services.AddHealthChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -244,37 +241,5 @@ namespace JiShe.CollectBus.Host
|
|||||||
.SetUdpDataHandlingAdapter(() => new NormalUdpDataHandlingAdapter());
|
.SetUdpDataHandlingAdapter(() => new NormalUdpDataHandlingAdapter());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 健康检查
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context"></param>
|
|
||||||
/// <param name="configuration"></param>
|
|
||||||
private void ConfigureHealthChecks(ServiceConfigurationContext context, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
if (!configuration.GetValue<bool>("HealthChecks:IsEnable")) return;
|
|
||||||
var cassandraConfig = new CassandraConfig();
|
|
||||||
configuration.GetSection("Cassandra").Bind(cassandraConfig);
|
|
||||||
context.Services.AddHealthChecks()
|
|
||||||
.AddMongoDb(configuration.GetConnectionString("Default"), "MongoDB", HealthStatus.Unhealthy)
|
|
||||||
.AddRedis(configuration.GetValue<string>("Redis:Configuration") ?? string.Empty, "Redis",
|
|
||||||
HealthStatus.Unhealthy)
|
|
||||||
.AddKafka(new Confluent.Kafka.ProducerConfig
|
|
||||||
{
|
|
||||||
BootstrapServers = configuration.GetConnectionString("Kafka")
|
|
||||||
}, "Kafka", failureStatus: HealthStatus.Unhealthy)
|
|
||||||
|
|
||||||
.AddCheck<CassandraHealthCheck>("Cassandra")
|
|
||||||
.AddCheck<IoTdbHealthCheck>("IoTDB");
|
|
||||||
|
|
||||||
context.Services
|
|
||||||
.AddHealthChecksUI(options =>
|
|
||||||
{
|
|
||||||
options.AddHealthCheckEndpoint("JiSheCollectBus", "/health"); // 映射本地端点
|
|
||||||
})
|
|
||||||
.AddInMemoryStorage();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
using HealthChecks.UI.Client;
|
|
||||||
using JiShe.CollectBus.Host.Extensions;
|
using JiShe.CollectBus.Host.Extensions;
|
||||||
using JiShe.CollectBus.Host.HealthChecks;
|
using JiShe.CollectBus.Host.HealthChecks;
|
||||||
using JiShe.CollectBus.Host.Swaggers;
|
using JiShe.CollectBus.Host.Swaggers;
|
||||||
@ -46,9 +45,9 @@ namespace JiShe.CollectBus.Host
|
|||||||
ConfigureNetwork(context, configuration);
|
ConfigureNetwork(context, configuration);
|
||||||
ConfigureJwtAuthentication(context, configuration);
|
ConfigureJwtAuthentication(context, configuration);
|
||||||
ConfigureHangfire(context);
|
ConfigureHangfire(context);
|
||||||
|
//ConfigureKafkaTopic(context, configuration);
|
||||||
ConfigureAuditLog(context);
|
ConfigureAuditLog(context);
|
||||||
ConfigureCustom(context, configuration);
|
ConfigureCustom(context, configuration);
|
||||||
ConfigureHealthChecks(context, configuration);
|
|
||||||
Configure<AbpClockOptions>(options => { options.Kind = DateTimeKind.Local; });
|
Configure<AbpClockOptions>(options => { options.Kind = DateTimeKind.Local; });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,16 +89,11 @@ namespace JiShe.CollectBus.Host
|
|||||||
});
|
});
|
||||||
app.UseConfiguredEndpoints(endpoints =>
|
app.UseConfiguredEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
if (!configuration.GetValue<bool>("HealthChecks:IsEnable")) return;
|
|
||||||
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
||||||
{
|
{
|
||||||
Predicate = _ => true,
|
Predicate = _ => true,
|
||||||
ResponseWriter = HealthCheckResponse.Writer
|
ResponseWriter = HealthCheckResponse.Writer
|
||||||
});
|
});
|
||||||
endpoints.MapHealthChecksUI(options =>
|
|
||||||
{
|
|
||||||
options.UIPath = "/health-ui";
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
using Cassandra;
|
|
||||||
using JiShe.CollectBus.Cassandra;
|
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Host.HealthChecks
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// CassandraHealthCheck
|
|
||||||
/// </summary>
|
|
||||||
/// <seealso cref="Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck" />
|
|
||||||
public class CassandraHealthCheck : IHealthCheck
|
|
||||||
{
|
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="CassandraHealthCheck"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configuration">The configuration.</param>
|
|
||||||
public CassandraHealthCheck(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
_configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Runs the health check, returning the status of the component being checked.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">A context object associated with the current execution.</param>
|
|
||||||
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the health check.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="T:System.Threading.Tasks.Task`1" /> that completes when the health check has finished, yielding the status of the component being checked.
|
|
||||||
/// </returns>
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var cassandraConfig = new CassandraConfig();
|
|
||||||
_configuration.GetSection("Cassandra").Bind(cassandraConfig);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var clusterBuilder = Cluster.Builder();
|
|
||||||
foreach (var node in cassandraConfig.Nodes)
|
|
||||||
{
|
|
||||||
clusterBuilder.AddContactPoint(node.Host)
|
|
||||||
.WithPort(node.Port);
|
|
||||||
}
|
|
||||||
clusterBuilder.WithCredentials(cassandraConfig.Username, cassandraConfig.Password);
|
|
||||||
var cluster = clusterBuilder.Build();
|
|
||||||
using var session = await cluster.ConnectAsync();
|
|
||||||
var result = await Task.FromResult(session.Execute("SELECT release_version FROM system.local"));
|
|
||||||
var version = result.First().GetValue<string>("release_version");
|
|
||||||
return HealthCheckResult.Healthy($"Cassandra is healthy. Version: {version}");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return new HealthCheckResult(context.Registration.FailureStatus, $"Cassandra is unhealthy: {ex.Message}", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
using System.Net.Sockets;
|
|
||||||
using JiShe.CollectBus.Cassandra;
|
|
||||||
using JiShe.CollectBus.IoTDB.Interface;
|
|
||||||
using JiShe.CollectBus.IoTDB.Options;
|
|
||||||
using JiShe.CollectBus.IoTDB.Provider;
|
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Host.HealthChecks
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// IoTDBHealthCheck
|
|
||||||
/// </summary>
|
|
||||||
/// <seealso cref="Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck" />
|
|
||||||
public class IoTdbHealthCheck : IHealthCheck
|
|
||||||
{
|
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="IoTdbHealthCheck"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configuration">The configuration.</param>
|
|
||||||
public IoTdbHealthCheck(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
_configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Runs the health check, returning the status of the component being checked.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">A context object associated with the current execution.</param>
|
|
||||||
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> that can be used to cancel the health check.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A <see cref="T:System.Threading.Tasks.Task`1" /> that completes when the health check has finished, yielding the status of the component being checked.
|
|
||||||
/// </returns>
|
|
||||||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ioTDbOptions = new IoTDbOptions();
|
|
||||||
_configuration.GetSection("IoTDBOptions").Bind(ioTDbOptions);
|
|
||||||
var pool = new SessionPoolAdapter(ioTDbOptions);
|
|
||||||
await pool.OpenAsync();
|
|
||||||
return HealthCheckResult.Healthy($"IoTDB is healthy.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return new HealthCheckResult(context.Registration.FailureStatus, $"IoTDB不健康: {ex.Message}", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -20,14 +20,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Kafka" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="8.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
|
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="9.0.0" />
|
|
||||||
|
|
||||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.4" />
|
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.4" />
|
||||||
|
<PackageReference Include="MassTransit" Version="8.4.0" />
|
||||||
|
<PackageReference Include="MassTransit.Kafka" Version="8.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="9.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
|
||||||
<title>后端服务</title>
|
<title>后端服务</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -52,13 +53,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||||
<div class="thumbnail" style="height: 180px">
|
<div class="thumbnail" style="height: 180px">
|
||||||
<a href="@CollectBusHostConst.HealthDashboardEndPoint" target="_blank">
|
<a href="@CollectBusHostConst.CapDashboardEndPoint" target="_blank">
|
||||||
<img class="lazy" src="/images/hangfire.png" width="300" height="150" />
|
<img class="lazy" src="/images/cap.png" width="300" height="150"/>
|
||||||
</a>
|
</a>
|
||||||
<div class="caption">
|
<div class="caption">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="@CollectBusHostConst.HealthEndPoint" target="_blank">健康检查API</a> |
|
<a href="@CollectBusHostConst.CapDashboardEndPoint" target="_blank">CAP</a>
|
||||||
<a href="@CollectBusHostConst.HealthDashboardEndPoint" target="_blank">UI</a>
|
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -86,7 +86,6 @@
|
|||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
width: 1170px;
|
width: 1170px;
|
||||||
padding-right: 15px;
|
padding-right: 15px;
|
||||||
@ -94,7 +93,6 @@
|
|||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.projects-header {
|
.projects-header {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -102,18 +100,15 @@
|
|||||||
display: block;
|
display: block;
|
||||||
margin: 60px auto 40px !important;
|
margin: 60px auto 40px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
padding-bottom: 9px;
|
padding-bottom: 9px;
|
||||||
margin: 40px auto;
|
margin: 40px auto;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.projects-header h2 {
|
.projects-header h2 {
|
||||||
font-size: 42px;
|
font-size: 42px;
|
||||||
letter-spacing: -1px;
|
letter-spacing: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
@ -122,20 +117,16 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
/* text-align: center; */
|
/* text-align: center; */
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0 0 10px;
|
margin: 0 0 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
margin-right: -15px;
|
margin-right: -15px;
|
||||||
margin-left: -15px;
|
margin-left: -15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.col-lg-3 {
|
.col-lg-3 {
|
||||||
width: 25%;
|
width: 25%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.projects .thumbnail {
|
.projects .thumbnail {
|
||||||
display: block;
|
display: block;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
@ -144,7 +135,6 @@
|
|||||||
margin-bottom: 30px;
|
margin-bottom: 30px;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumbnail {
|
.thumbnail {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
@ -153,24 +143,20 @@
|
|||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
.transition(border 0.2s ease-in-out);
|
.transition(border 0.2s ease-in-out);
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #337ab7;
|
color: #337ab7;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.projects .thumbnail img {
|
.projects .thumbnail img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumbnail a > img,
|
.thumbnail a > img,
|
||||||
.thumbnail > img {
|
.thumbnail > img {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace JiShe.CollectBus.Host.Pages
|
|||||||
{
|
{
|
||||||
public class Monitor : PageModel
|
public class Monitor : PageModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using JiShe.CollectBus.Host;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Volo.Abp.Modularity.PlugIns;
|
using Volo.Abp.Modularity.PlugIns;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Host;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Program
|
|
||||||
/// </summary>
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Main
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -23,13 +19,47 @@ public class Program
|
|||||||
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
|
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
|
||||||
})
|
})
|
||||||
.UseAutofac();
|
.UseAutofac();
|
||||||
var configuration = builder.Configuration;
|
|
||||||
await builder.AddApplicationAsync<CollectBusHostModule>(options =>
|
await builder.AddApplicationAsync<CollectBusHostModule>(options =>
|
||||||
{
|
{
|
||||||
options.PlugInSources.AddFolder((configuration["PlugInFolder"].IsNullOrWhiteSpace()? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"): configuration["PlugInFolder"]) ?? string.Empty);
|
// 加载插件,固定模式,可热插拔
|
||||||
|
options.PlugInSources.AddFolder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"));
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
await app.InitializeApplicationAsync();
|
await app.InitializeApplicationAsync();
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
|
|
||||||
|
|
||||||
|
//await CreateHostBuilder(args).Build().RunAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseSerilog((context, loggerConfiguration) =>
|
||||||
|
{
|
||||||
|
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
|
||||||
|
})
|
||||||
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
|
{
|
||||||
|
webBuilder.UseStartup<Startup>();
|
||||||
|
})
|
||||||
|
.UseAutofac();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static IHostBuilder CreateConsoleHostBuilder(string[] args) =>
|
||||||
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.ConfigureServices((hostContext, services) => { ConfigureServices(services, hostContext); })
|
||||||
|
.UseAutofac()
|
||||||
|
.UseSerilog((context, loggerConfiguration) =>
|
||||||
|
{
|
||||||
|
loggerConfiguration.ReadFrom.Configuration(context.Configuration);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
private static async Task ConfigureServices(IServiceCollection services, HostBuilderContext hostContext)
|
||||||
|
{
|
||||||
|
await services.AddApplicationAsync<CollectBusHostModule>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
53
web/JiShe.CollectBus.Host/Startup.cs
Normal file
53
web/JiShe.CollectBus.Host/Startup.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using TouchSocket.Core;
|
||||||
|
using Volo.Abp.Modularity.PlugIns;
|
||||||
|
|
||||||
|
namespace JiShe.CollectBus.Host
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Startup
|
||||||
|
/// </summary>
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Startup"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">The configuration.</param>
|
||||||
|
public Startup(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the services.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services">The services.</param>
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddApplication<CollectBusHostModule>(options =>
|
||||||
|
{
|
||||||
|
// 加载插件,固定模式,可热插拔
|
||||||
|
options.PlugInSources.AddFolder(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the specified application.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app">The application.</param>
|
||||||
|
/// <param name="lifetime">The lifetime.</param>
|
||||||
|
public void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime)
|
||||||
|
{
|
||||||
|
|
||||||
|
app.Use(async (context, next) =>
|
||||||
|
{
|
||||||
|
// 在请求处理之前调用 InitializeApplicationAsync
|
||||||
|
await app.InitializeApplicationAsync();
|
||||||
|
|
||||||
|
// 继续请求管道中的下一个中间件
|
||||||
|
await next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,11 +51,16 @@
|
|||||||
"Issuer": "JiShe.CollectBus",
|
"Issuer": "JiShe.CollectBus",
|
||||||
"ExpirationTime": 2
|
"ExpirationTime": 2
|
||||||
},
|
},
|
||||||
"HealthChecks": {
|
"HealthCheck": {
|
||||||
"IsEnable": true,
|
"IsEnable": true,
|
||||||
"HealthCheckDatabaseName": "HealthChecks",
|
"MySql": {
|
||||||
"EvaluationTimeInSeconds": 10,
|
"IsEnable": true
|
||||||
"MinimumSecondsBetweenFailureNotifications": 60
|
},
|
||||||
|
"Pings": {
|
||||||
|
"IsEnable": true,
|
||||||
|
"Host": "https://www.baidu.com/",
|
||||||
|
"TimeOut": 5000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"SwaggerConfig": [
|
"SwaggerConfig": [
|
||||||
{
|
{
|
||||||
@ -79,7 +84,7 @@
|
|||||||
"SaslPassword": "lixiao1980",
|
"SaslPassword": "lixiao1980",
|
||||||
"KafkaReplicationFactor": 3,
|
"KafkaReplicationFactor": 3,
|
||||||
"NumPartitions": 30,
|
"NumPartitions": 30,
|
||||||
"ServerTagName": "JiSheCollectBus30",
|
"ServerTagName": "JiSheCollectBus99",
|
||||||
"FirstCollectionTime": "2025-04-22 16:07:00"
|
"FirstCollectionTime": "2025-04-22 16:07:00"
|
||||||
},
|
},
|
||||||
"IoTDBOptions": {
|
"IoTDBOptions": {
|
||||||
@ -139,6 +144,5 @@
|
|||||||
"SerialConsistencyLevel": "Serial",
|
"SerialConsistencyLevel": "Serial",
|
||||||
"DefaultIdempotence": true
|
"DefaultIdempotence": true
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"PlugInFolder": ""
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user