Add metrics
This commit is contained in:
@ -48,5 +48,6 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Nostr.Client" Version="1.4.2" />
|
<PackageReference Include="Nostr.Client" Version="1.4.2" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||||
|
<PackageReference Include="prometheus-net.AspNetCore" Version="8.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -10,6 +10,7 @@ using NostrStreamer.Services.Background;
|
|||||||
using NostrStreamer.Services.Dvr;
|
using NostrStreamer.Services.Dvr;
|
||||||
using NostrStreamer.Services.StreamManager;
|
using NostrStreamer.Services.StreamManager;
|
||||||
using NostrStreamer.Services.Thumbnail;
|
using NostrStreamer.Services.Thumbnail;
|
||||||
|
using Prometheus;
|
||||||
|
|
||||||
namespace NostrStreamer;
|
namespace NostrStreamer;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ internal static class Program
|
|||||||
|
|
||||||
var services = builder.Services;
|
var services = builder.Services;
|
||||||
var config = builder.Configuration.GetSection("Config").Get<Config>();
|
var config = builder.Configuration.GetSection("Config").Get<Config>();
|
||||||
|
|
||||||
ConfigureDb(services, builder.Configuration);
|
ConfigureDb(services, builder.Configuration);
|
||||||
services.AddCors();
|
services.AddCors();
|
||||||
services.AddMemoryCache();
|
services.AddMemoryCache();
|
||||||
@ -29,11 +30,11 @@ internal static class Program
|
|||||||
services.AddRazorPages();
|
services.AddRazorPages();
|
||||||
services.AddControllers().AddNewtonsoftJson();
|
services.AddControllers().AddNewtonsoftJson();
|
||||||
services.AddSingleton(config);
|
services.AddSingleton(config);
|
||||||
|
|
||||||
// GeoIP
|
// GeoIP
|
||||||
services.AddSingleton<IGeoIP2DatabaseReader>(_ => new DatabaseReader(config.GeoIpDatabase));
|
services.AddSingleton<IGeoIP2DatabaseReader>(_ => new DatabaseReader(config.GeoIpDatabase));
|
||||||
services.AddTransient<EdgeSteering>();
|
services.AddTransient<EdgeSteering>();
|
||||||
|
|
||||||
// nostr auth
|
// nostr auth
|
||||||
services.AddTransient<NostrAuthHandler>();
|
services.AddTransient<NostrAuthHandler>();
|
||||||
services.AddAuthentication(o =>
|
services.AddAuthentication(o =>
|
||||||
@ -49,14 +50,14 @@ internal static class Program
|
|||||||
new ClaimsAuthorizationRequirement(ClaimTypes.Name, null)
|
new ClaimsAuthorizationRequirement(ClaimTypes.Name, null)
|
||||||
}, new[] {NostrAuth.Scheme});
|
}, new[] {NostrAuth.Scheme});
|
||||||
});
|
});
|
||||||
|
|
||||||
// nostr services
|
// nostr services
|
||||||
services.AddSingleton<NostrMultiWebsocketClient>();
|
services.AddSingleton<NostrMultiWebsocketClient>();
|
||||||
services.AddSingleton<INostrClient>(s => s.GetRequiredService<NostrMultiWebsocketClient>());
|
services.AddSingleton<INostrClient>(s => s.GetRequiredService<NostrMultiWebsocketClient>());
|
||||||
services.AddSingleton<NostrListener>();
|
services.AddSingleton<NostrListener>();
|
||||||
services.AddHostedService<NostrListenerLifetime>();
|
services.AddHostedService<NostrListenerLifetime>();
|
||||||
services.AddTransient<ZapService>();
|
services.AddTransient<ZapService>();
|
||||||
|
|
||||||
// streaming services
|
// streaming services
|
||||||
services.AddTransient<SrsApi>();
|
services.AddTransient<SrsApi>();
|
||||||
services.AddHostedService<BackgroundStreamManager>();
|
services.AddHostedService<BackgroundStreamManager>();
|
||||||
@ -69,11 +70,11 @@ internal static class Program
|
|||||||
services.AddTransient<IThumbnailService, S3ThumbnailService>();
|
services.AddTransient<IThumbnailService, S3ThumbnailService>();
|
||||||
services.AddHostedService<ThumbnailGenerator>();
|
services.AddHostedService<ThumbnailGenerator>();
|
||||||
services.AddTransient<IDvrStore, S3DvrStore>();
|
services.AddTransient<IDvrStore, S3DvrStore>();
|
||||||
|
|
||||||
// lnd services
|
// lnd services
|
||||||
services.AddSingleton<LndNode>();
|
services.AddSingleton<LndNode>();
|
||||||
services.AddHostedService<LndInvoicesStream>();
|
services.AddHostedService<LndInvoicesStream>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
@ -82,14 +83,18 @@ internal static class Program
|
|||||||
await db.Database.MigrateAsync();
|
await db.Database.MigrateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
app.UseCors(o => o.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
|
app.UseCors(o => o.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
|
||||||
|
app.UseHttpMetrics();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapRazorPages();
|
app.MapRazorPages();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
app.MapMetrics();
|
||||||
|
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureDb(IServiceCollection services, IConfiguration configuration)
|
private static void ConfigureDb(IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddDbContext<StreamerContext>(o => o.UseNpgsql(configuration.GetConnectionString("Database")));
|
services.AddDbContext<StreamerContext>(o => o.UseNpgsql(configuration.GetConnectionString("Database")));
|
||||||
@ -108,4 +113,4 @@ internal static class Program
|
|||||||
|
|
||||||
return dummyHost;
|
return dummyHost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user