remove locks around metrics for testing, add back dbcontext pooling
This commit is contained in:
@@ -13,10 +13,10 @@ namespace MareSynchronosServer.Metrics
|
||||
|
||||
public void Inc(double inc = 1d)
|
||||
{
|
||||
lock (_c)
|
||||
{
|
||||
//lock (_c)
|
||||
//{
|
||||
_c.Inc(inc);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,34 +13,34 @@ public class LockedProxyGauge
|
||||
|
||||
public void Inc(double inc = 1d)
|
||||
{
|
||||
lock (_g)
|
||||
{
|
||||
//lock (_g)
|
||||
//{
|
||||
_g.Inc(inc);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void IncTo(double incTo)
|
||||
{
|
||||
lock (_g)
|
||||
{
|
||||
//lock (_g)
|
||||
//{
|
||||
_g.IncTo(incTo);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void Dec(double decBy = 1d)
|
||||
{
|
||||
lock (_g)
|
||||
{
|
||||
//lock (_g)
|
||||
//{
|
||||
_g.Dec(decBy);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void Set(double setTo)
|
||||
{
|
||||
lock (_g)
|
||||
{
|
||||
//lock (_g)
|
||||
//{
|
||||
_g.Set(setTo);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public double Value => _g.Value;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace MareSynchronosServer
|
||||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var context = services.GetRequiredService<MareDbContext>();
|
||||
using var context = services.GetRequiredService<MareDbContext>();
|
||||
context.Database.Migrate();
|
||||
context.SaveChanges();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using MareSynchronos.API;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -13,7 +12,6 @@ using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Prometheus;
|
||||
using WebSocketOptions = Microsoft.AspNetCore.Builder.WebSocketOptions;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using MareSynchronosServer.Discord;
|
||||
@@ -48,13 +46,14 @@ namespace MareSynchronosServer
|
||||
services.AddSingleton<IUserIdProvider, IdBasedUserIdProvider>();
|
||||
services.AddTransient(_ => Configuration);
|
||||
|
||||
services.AddDbContext<MareDbContext>(options =>
|
||||
services.AddDbContextPool<MareDbContext>(options =>
|
||||
{
|
||||
options.EnableThreadSafetyChecks(false);
|
||||
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"), builder =>
|
||||
{
|
||||
builder.MigrationsHistoryTable("_efmigrationshistory", "public");
|
||||
}).UseSnakeCaseNamingConvention();
|
||||
});
|
||||
}, Configuration.GetValue("DbContextPoolSize", 1024));
|
||||
|
||||
services.AddHostedService<CleanupService>();
|
||||
services.AddHostedService(provider => provider.GetService<SystemInfoService>());
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"DbContextPoolSize": 2000,
|
||||
"CdnFullUrl": "https://<url or ip to your server>/cache/",
|
||||
"FailedAuthForTempBan": 5,
|
||||
"TempBanDurationInMinutes": 30,
|
||||
|
||||
Reference in New Issue
Block a user