Comments (11)
Yes it's working. Thanks
from beatpulse.
Hi @sorcer1
Yes, we have an issue in BeatPulse, because we haven't parametrized LivenessDb context constructor. So you are register another DbContext and the error is clear.
Should be
public LivenessDb(DbContextOptions<LivenessDb> options) : base(options) { }
We are going to fix it!
from beatpulse.
Hi @sorcer1
Are you trying to enable UI in your Web API? ( UI is intended to be a different project)
You need also UseBeatPulseUI in your Configure method.
Can you post your code on a gist in order to check? or sendus a copy, git uri etc..
from beatpulse.
Yes, i want to have UI in my Web API.
The UseBeatPulseUI is already in my Configure method.
The UI is shown but with an error : Could not retrieve liveness data
from beatpulse.
Hi @sorcer1 ,
Can you share with us your Startup.cs?
Regards!
from beatpulse.
Hi @sorcer1
I create a sample app with your scenario and is working, can you send me a repro of the problem?
from beatpulse.
using BeatPulse;
using BeatPulse.UI;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using MovieSystem.Api.Core.Extensions;
using MovieSystem.Api.Core.Middlewares;
using MovieSystem.Api.Core.Swagger;
using MovieSystem.Infrastructures.Interfaces;
using MovieSystem.Infrastructures.Security;
using MovieSystem.Server.Config;
using MovieSystem.Server.Config.Interfaces;
using MovieSystemV4.Data;
using MovieSystemV4.Data.Interfaces;
using MovieSystemV4.Data.Models;
using MovieSystemV4.Repositories;
using MovieSystemV4.Repositories.Interfaces;
using MovieSystemV4.Services;
using MovieSystemV4.Services.Interfaces;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace MovieSystemV4.Api
{
public class Startup
{
public static IHostingEnvironment HostingEnvironment;
public Startup(IHostingEnvironment hostingEnvironment)
{
HostingEnvironment = hostingEnvironment;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
// Configure health checks
ConfigureHealthChecks(services);
// Configures the service authentification
ConfigureServiceAuthentication(services);
// Config the database context
ConfigureServiceDbContext(services);
// Add services by Dependency Injection
ConfigureServicesByDependencyInjection(services);
// Add CORS to enable security
services.AddCors();
// Config compression for https
services.AddResponseCompression(options => { options.EnableForHttps = true; });
// Config the cache
ConfigureCache(services);
services.AddMvc()
// Add JSON options to MVC rendering
.AddJsonOptions(jsonOptions =>
{
jsonOptions.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
jsonOptions.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});
// Configure API Versioning
ConfigureApiVersioning(services);
// TODO : ajout de la gestion des profils
// x-profile-id: 50
// Configure swagger api documentation
ConfigureSwagger(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseBeatPulseUI();
app.UseCors(c => c
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
if (HostingEnvironment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/error");
app.UseHsts();
}
app.UseHttpsRedirection();
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MOVIESYSTEM API V1");
c.DocumentTitle = "MovieSystem API Documentation";
});
app.UseAuthentication();
app.UseResponseCompression();
app.UseRequestResponseLogging();
app.UseMvc();
}
private static void ConfigureSwagger(IServiceCollection services)
{
//...
}
private static void ConfigureApiVersioning(IServiceCollection services)
{
//...
}
private static void ConfigureServiceDbContext(IServiceCollection services)
{
//...
}
private static void ConfigureCache(IServiceCollection services)
{
//...
}
private static void ConfigureHealthChecks(IServiceCollection services)
{
services.AddBeatPulseUI();
services.AddBeatPulse(setup =>
{
setup.AddSqlServer("myConnectionString");
});
}
private static void ConfigureServiceAuthentication(IServiceCollection services)
{
//...
}
private static void ConfigureServicesByDependencyInjection(IServiceCollection services)
{
//...
}
}
}
from beatpulse.
More details about the error :
MovieSystemV4.Api> [14:20:43 ERR] Connection id "0HLEGBRB1HRQM", Request id "0HLEGBRB1HRQM:00000002": An unhandled exception was thrown by the application.
MovieSystemV4.Api> System.InvalidOperationException: The DbContextOptions passed to the LivenessDb constructor must be a DbContextOptions<LivenessDb>. When registering multiple DbContext types make sure that the constructor for each context type has a DbContextOptions<TContext> parameter rather than a non-generic DbContextOptions parameter.
MovieSystemV4.Api> at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
MovieSystemV4.Api> at lambda_method(Closure , ServiceProviderEngineScope )
MovieSystemV4.Api> at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
MovieSystemV4.Api> at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
MovieSystemV4.Api> at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
MovieSystemV4.Api> at BeatPulse.UI.Middleware.UIApiEndpointMiddleware.InvokeAsync(HttpContext context, IServiceScopeFactory serviceScopeFactory)
MovieSystemV4.Api> at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
MovieSystemV4.Api> at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
MovieSystemV4.Api> at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
MovieSystemV4.Api> at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
from beatpulse.
good
from beatpulse.
Fixed!
Version 2.1.1 BeatPulseUI.
from beatpulse.
@sorcer1 Is working?
from beatpulse.
Related Issues (20)
- Custom response HOT 2
- BeatPulse UI show old state after degraded one of services
- BeatPulse.Redis has reference to unsuported StackExchange.Redis.StrongName package HOT 2
- Inconsistent log level used in liveness checkers HOT 1
- Liveness checkers logs connection string HOT 1
- Question : Call health check from code HOT 1
- GetAllLiveness not accessible when creating new BeatPulse for Akka
- Adding multiple liveness results in Exception, "More then one sequence found" HOT 1
- Disable logs
- Add deprecated status to this repo HOT 2
- Liveness configuration from configuration file HOT 1
- Add Elasticsearch Provider HOT 2
- [BeatPulse-UI] Impossible to display data HOT 10
- UI behind reverse proxy HOT 14
- How to use beatpulse in iis authentication
- Incorrect NuGet Package HOT 7
- Redis livepoint creates numerous connections to Redis HOT 9
- Question: Can beatpulse be used with MVC 5 apps and full framework windows services? HOT 3
- Migrate to new aspnet core version.
- BeatPulse UI memory leak HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beatpulse.