Compare commits
3 Commits
a1999bfe41
...
9847b6e6f7
| Author | SHA1 | Date | |
|---|---|---|---|
| 9847b6e6f7 | |||
| ada0e2f665 | |||
| b28bd2826b |
@@ -2,6 +2,8 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
using Vegasco.Server.Api.Authentication;
|
using Vegasco.Server.Api.Authentication;
|
||||||
using Vegasco.Server.Api.Common;
|
using Vegasco.Server.Api.Common;
|
||||||
using Vegasco.Server.Api.Persistence;
|
using Vegasco.Server.Api.Persistence;
|
||||||
@@ -27,6 +29,14 @@ public static class DependencyInjectionExtensions
|
|||||||
|
|
||||||
private static IServiceCollection AddMiscellaneousServices(this IServiceCollection services)
|
private static IServiceCollection AddMiscellaneousServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddSingleton(sp =>
|
||||||
|
{
|
||||||
|
var assemblyName = Assembly.GetExecutingAssembly()
|
||||||
|
.GetName()
|
||||||
|
.Name ?? "Vegasco.Server.Api";
|
||||||
|
return new ActivitySource(assemblyName);
|
||||||
|
});
|
||||||
|
|
||||||
services.AddResponseCompression();
|
services.AddResponseCompression();
|
||||||
|
|
||||||
services.AddValidatorsFromAssemblies(
|
services.AddValidatorsFromAssemblies(
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Vegasco.Server.Api.Persistence;
|
namespace Vegasco.Server.Api.Persistence;
|
||||||
|
|
||||||
public class ApplyMigrationsService(ILogger<ApplyMigrationsService> logger, IServiceScopeFactory scopeFactory)
|
public class ApplyMigrationsService(
|
||||||
|
ILogger<ApplyMigrationsService> logger,
|
||||||
|
IServiceScopeFactory scopeFactory,
|
||||||
|
ActivitySource activitySource)
|
||||||
: IHostedService
|
: IHostedService
|
||||||
{
|
{
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
using var activity = activitySource.StartActivity("ApplyMigrations");
|
||||||
|
|
||||||
logger.LogInformation("Starting migrations");
|
logger.LogInformation("Starting migrations");
|
||||||
|
|
||||||
using IServiceScope scope = scopeFactory.CreateScope();
|
using IServiceScope scope = scopeFactory.CreateScope();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public static class Constants
|
|||||||
{
|
{
|
||||||
public static class Projects
|
public static class Projects
|
||||||
{
|
{
|
||||||
public const string Api = "Vegasco_Server_Api";
|
public const string Api = "Vegasco.Server.Api";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Database
|
public static class Database
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Vegasco.Server.AppHost.Shared;
|
|||||||
IDistributedApplicationBuilder builder = DistributedApplication.CreateBuilder(args);
|
IDistributedApplicationBuilder builder = DistributedApplication.CreateBuilder(args);
|
||||||
|
|
||||||
IResourceBuilder<PostgresDatabaseResource> postgres = builder.AddPostgres(Constants.Database.ServiceName)
|
IResourceBuilder<PostgresDatabaseResource> postgres = builder.AddPostgres(Constants.Database.ServiceName)
|
||||||
|
.WithLifetime(ContainerLifetime.Persistent)
|
||||||
.WithDataVolume()
|
.WithDataVolume()
|
||||||
.AddDatabase(Constants.Database.Name);
|
.AddDatabase(Constants.Database.Name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user