98 lines
3.3 KiB
C#
98 lines
3.3 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Sentry;
|
|
using Sentry.AspNetCore;
|
|
using Sentry.Extensibility;
|
|
using Sledgemapper.Api.Infrastructure.Data;
|
|
|
|
namespace Sledgemapper.Api
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var host = CreateHostBuilder(args).Build();
|
|
CreateDbIfNotExists(host);
|
|
using (Sentry.SentrySdk.Init(o =>
|
|
{
|
|
o.Dsn = "https://dbd98432b84b445696dc2996e4e01c90@glitchtip.michelescandura.com/2";
|
|
o.MaxBreadcrumbs = 50;
|
|
o.Debug = true;
|
|
o.StackTraceMode = StackTraceMode.Enhanced;
|
|
o.AttachStacktrace = true;
|
|
o.Release = "1.0.0-alpha.3";
|
|
|
|
#if DEBUG
|
|
o.Environment = "dev";
|
|
#else
|
|
o.Environment = "production";
|
|
#endif
|
|
|
|
|
|
}))
|
|
// {
|
|
host.Run();
|
|
SentrySdk.CaptureMessage("Backend starting");
|
|
//}
|
|
}
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
Host.CreateDefaultBuilder(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseSentry(o =>
|
|
{
|
|
o.Dsn = "https://dbd98432b84b445696dc2996e4e01c90@glitchtip.michelescandura.com/2";
|
|
o.MaxRequestBodySize = RequestSize.Always;
|
|
o.MaxBreadcrumbs = 50;
|
|
o.Debug = true;
|
|
o.StackTraceMode = StackTraceMode.Enhanced;
|
|
o.AttachStacktrace = true;
|
|
o.Release = "1.0.0-alpha.3";
|
|
//o.TracesSampler = ctx =>
|
|
//{
|
|
// if (string.Equals(ctx.TryGetHttpRoute(), "/Home/Privacy", StringComparison.Ordinal))
|
|
// {
|
|
// // Collect fewer traces for this page
|
|
// return 0.3;
|
|
// }
|
|
|
|
// return 1;
|
|
//};
|
|
#if DEBUG
|
|
o.Environment = "dev";
|
|
#else
|
|
o.Environment = "production";
|
|
#endif
|
|
|
|
});
|
|
webBuilder.UseStartup<Startup>();
|
|
});
|
|
|
|
// public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
// Host.CreateDefaultBuilder(args)
|
|
// .ConfigureWebHostDefaults(webBuilder =>
|
|
// {
|
|
// webBuilder.UseStartup<Startup>();
|
|
// });
|
|
|
|
private static void CreateDbIfNotExists(IHost host)
|
|
{
|
|
using var scope = host.Services.CreateScope();
|
|
var services = scope.ServiceProvider;
|
|
try
|
|
{
|
|
var context = services.GetRequiredService<SledgemapperDbContext>();
|
|
// DbInitializer.Initialize(context);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var logger = services.GetRequiredService<ILogger<Program>>();
|
|
logger.LogError(ex, "An error occurred creating the DB.");
|
|
}
|
|
}
|
|
}
|
|
}
|