зеркало из https://github.com/SteeltoeOSS/Samples.git
Trying to run SpringBootAdmin sample
This commit is contained in:
Родитель
69143abc7b
Коммит
aefa3f71d0
|
@ -1,5 +1,7 @@
|
|||
using Steeltoe.Management.Endpoint.Info;
|
||||
using Steeltoe.Management.Info;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudFoundry
|
||||
{
|
||||
|
@ -11,11 +13,10 @@ namespace CloudFoundry
|
|||
/// <summary>
|
||||
/// This is where you add your information
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
public void Contribute(IInfoBuilder builder)
|
||||
public Task ContributeAsync(IInfoBuilder builder, CancellationToken cancellationToken)
|
||||
{
|
||||
// pass in the info
|
||||
builder.WithInfo("arbitraryInfo", new { someProperty = "someValue" });
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Steeltoe.Common.HealthChecks;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudFoundry
|
||||
{
|
||||
|
@ -9,15 +11,15 @@ namespace CloudFoundry
|
|||
{
|
||||
public string Id => "CustomHealthContributor";
|
||||
|
||||
|
||||
public HealthCheckResult Health()
|
||||
public Task<HealthCheckResult> CheckHealthAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new HealthCheckResult {
|
||||
Status = HealthStatus.UP, // this is used as part of the aggregate, it is not directly part of the middleware response
|
||||
Status = HealthStatus.Up, // this is used as part of the aggregate, it is not directly part of the middleware response
|
||||
Description = "This health check does not check anything"
|
||||
};
|
||||
result.Details.Add("status", HealthStatus.UP.ToString());
|
||||
return result;
|
||||
result.Details.Add("status", HealthStatus.Up.ToString());
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SteeltoeVersion>3.2.*</SteeltoeVersion>
|
||||
<SteeltoeVersion>4.0.*-*</SteeltoeVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GitInfoVersion>2.0.20</GitInfoVersion>
|
||||
<JsonNetVersion>11.0.3</JsonNetVersion>
|
||||
<JsonNetVersion>13.0.*</JsonNetVersion>
|
||||
<RabbitMQVersion>6.2.2</RabbitMQVersion>
|
||||
<AspNetCoreVersion>6.0.0</AspNetCoreVersion>
|
||||
<EFCoreVersion>6.0.0</EFCoreVersion>
|
||||
<AspNetCoreVersion>8.0.*</AspNetCoreVersion>
|
||||
<EFCoreVersion>8.0.*</EFCoreVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Steeltoe.Connector.MySql.EFCore;
|
||||
using Steeltoe.Connectors.EntityFrameworkCore.MySql;
|
||||
|
||||
namespace CloudFoundry
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace CloudFoundry
|
|||
}
|
||||
}
|
||||
|
||||
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<MyContext>
|
||||
/*public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<MyContext>
|
||||
{
|
||||
public MyContext CreateDbContext(string[] args)
|
||||
{
|
||||
|
@ -28,10 +28,10 @@ namespace CloudFoundry
|
|||
.AddJsonFile($"appsettings.Development.json", optional: true)
|
||||
.Build();
|
||||
var services = new ServiceCollection();
|
||||
services.AddDbContext<MyContext>(options => options.UseMySql(config), ServiceLifetime.Singleton);
|
||||
services.AddDbContext<MyContext>(options => options.UseMySql(config));
|
||||
var container = services.BuildServiceProvider();
|
||||
var context = container.GetRequiredService<MyContext>();
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Builder;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Steeltoe.Management.Endpoint;
|
||||
using Steeltoe.Extensions.Configuration.CloudFoundry;
|
||||
using Steeltoe.Configuration.CloudFoundry;
|
||||
|
||||
namespace SpringBootAdmin
|
||||
{
|
||||
|
@ -18,8 +18,10 @@ namespace SpringBootAdmin
|
|||
.AddCloudFoundryConfiguration()
|
||||
.ConfigureWebHost(configure =>
|
||||
{
|
||||
configure.UseStartup<Startup>().UseKestrel();
|
||||
configure.UseUrls("http://host.docker.internal:5000");
|
||||
//configure.UseStartup<Startup>().UseKestrel();
|
||||
configure.UseStartup<Startup>().UseIIS();
|
||||
//configure.UseUrls("http://host.docker.internal:5000");
|
||||
//configure.UseUrls("http://localhost:5000");
|
||||
})
|
||||
.AddAllActuators(endpoints => endpoints.RequireAuthorization("actuators.read"))
|
||||
.Build();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -11,20 +11,31 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="idunno.Authentication.Basic" Version="2.2.2" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EFCoreVersion)" />
|
||||
<!--
|
||||
<PackageReference Include="Steeltoe.Common.Hosting" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Connector.EFCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Connector.ConnectorCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Connector.CloudFoundry" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Management.EndpointCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Management.TaskCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Connectors.EntityFrameworkCore" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Connectors" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Configuration.CloudFoundry" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Management.Endpoint" Version="$(SteeltoeVersion)" />
|
||||
<PackageReference Include="Steeltoe.Management.Task" Version="$(SteeltoeVersion)" />
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="git.properties" CopyToOutputDirectory="PreserveNewest" />
|
||||
<None Include="appsettings.json" CopyToOutputDirectory="Always" />
|
||||
<None Include="appsettings.Development.json" CopyToOutputDirectory="Always" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Common\src\Common.Hosting\Steeltoe.Common.Hosting.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Configuration\src\CloudFoundry\Steeltoe.Configuration.CloudFoundry.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Connectors\src\Connectors\Steeltoe.Connectors.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Connectors\src\EntityFrameworkCore\Steeltoe.Connectors.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Management\src\Endpoint\Steeltoe.Management.Endpoint.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\Steeltoe\src\Management\src\Task\Steeltoe.Management.Task.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="_GitProperties" AfterTargets="CoreCompile">
|
||||
<WriteLinesToFile File="git.properties" Lines="git.remote.origin.url=$(GitRoot)" Overwrite="true" />
|
||||
<WriteLinesToFile File="git.properties" Lines="git.build.version=$(GitBaseVersion)" Overwrite="false" />
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace SpringBootAdmin
|
|||
options.AddPolicy("actuators.read", policy => policy.RequireClaim("scope", "actuators.read"));
|
||||
});
|
||||
|
||||
services.AddSpringBootAdminClient();
|
||||
|
||||
// Add framework services.
|
||||
services.AddControllersWithViews();
|
||||
}
|
||||
|
@ -76,7 +78,7 @@ namespace SpringBootAdmin
|
|||
// Start up the metrics forwarder service added above
|
||||
// Remove comment below to enable
|
||||
// app.UseMetricsExporter();
|
||||
app.RegisterWithSpringBootAdmin(Configuration);
|
||||
//app.RegisterWithSpringBootAdmin(Configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
"boot": {
|
||||
"admin": {
|
||||
"client": {
|
||||
"basePath": "http://localhost:5000",
|
||||
"url": "http://localhost:8080",
|
||||
"metadata": {
|
||||
"user.name": "actuatorUser",
|
||||
|
|
Загрузка…
Ссылка в новой задаче