This commit is contained in:
@@ -11,7 +11,6 @@ UPDATE all the things before commencing work
|
||||
- https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcoreannotations
|
||||
-
|
||||
|
||||
- Get tests passing
|
||||
- See about Metrics which is currently commented out in startup, maybe not an issue right now?!
|
||||
- Read this and see if more areas where I need to update my code to the modern standard: https://kimsereyblog.blogspot.com/2018/08/apicontroller-attribute-in-asp-net-core.html
|
||||
- Find and read changes for 3.1 dotnet core and Note that that above is for v2.2 my controllers appear to date from the v1 .net core era and I will need to then move them to the .netcore 3.1 era changes
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -32,6 +33,10 @@ namespace AyaNova
|
||||
ServerBootConfig.SetConfiguration(config);
|
||||
|
||||
#region Initialize Logging
|
||||
//NOTE: there is a logging issue that breaks all this with .net 3.1 hostbuilder vs webhostbuilder but webhostbuilder will be deprecated so we need to work around it
|
||||
//the discussion about that is here: https://github.com/aspnet/AspNetCore/issues/9337
|
||||
|
||||
//NLOG OFFICIAL GUIDELINES FOR .net core 3.x https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-3
|
||||
|
||||
//default log level
|
||||
NLog.LogLevel NLogLevel = NLog.LogLevel.Info;
|
||||
@@ -185,7 +190,8 @@ namespace AyaNova
|
||||
|
||||
try
|
||||
{
|
||||
BuildWebHost(args, logger).Run();
|
||||
//BuildWebHost(args, logger).Run();
|
||||
BuildHost(args, logger).Build().Run();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -196,6 +202,75 @@ namespace AyaNova
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static IHostBuilder BuildHost(string[] args, NLog.Logger logger)
|
||||
{
|
||||
logger.Debug("BOOT: building host");
|
||||
var configuration = new ConfigurationBuilder().AddCommandLine(args).Build();
|
||||
|
||||
return Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder
|
||||
.UseSetting("detailedErrors", "true")
|
||||
.UseUrls(ServerBootConfig.AYANOVA_USE_URLS)//default port and urls, set first can be overridden by any later setting here
|
||||
.UseConfiguration(configuration)//support command line override of port (dotnet run urls=http://*:8081)
|
||||
.UseIISIntegration()//support IIS integration just in case, it appears here to override prior settings if necessary (port)
|
||||
.ConfigureMetricsWithDefaults(builder =>
|
||||
{
|
||||
if (ServerBootConfig.AYANOVA_METRICS_USE_INFLUXDB)
|
||||
{
|
||||
builder.Report.ToInfluxDb(
|
||||
options =>
|
||||
{
|
||||
|
||||
options.InfluxDb.BaseUri = new Uri(ServerBootConfig.AYANOVA_METRICS_INFLUXDB_BASEURL);
|
||||
options.InfluxDb.Database = ServerBootConfig.AYANOVA_METRICS_INFLUXDB_DBNAME;
|
||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_METRICS_INFLUXDB_CONSISTENCY))
|
||||
{
|
||||
options.InfluxDb.Consistenency = ServerBootConfig.AYANOVA_METRICS_INFLUXDB_CONSISTENCY;
|
||||
}
|
||||
options.InfluxDb.UserName = ServerBootConfig.AYANOVA_METRICS_INFLUXDB_USERNAME;
|
||||
options.InfluxDb.Password = ServerBootConfig.AYANOVA_METRICS_INFLUXDB_PASSWORD;
|
||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_METRICS_INFLUXDB_RETENTION_POLICY))
|
||||
{
|
||||
options.InfluxDb.RetentionPolicy = ServerBootConfig.AYANOVA_METRICS_INFLUXDB_RETENTION_POLICY;
|
||||
}
|
||||
|
||||
options.InfluxDb.CreateDataBaseIfNotExists = true;
|
||||
options.HttpPolicy.BackoffPeriod = TimeSpan.FromSeconds(30);
|
||||
options.HttpPolicy.FailuresBeforeBackoff = 5;
|
||||
options.HttpPolicy.Timeout = TimeSpan.FromSeconds(10);
|
||||
//options.MetricsOutputFormatter = new App.Metrics.Formatters.Json.MetricsJsonOutputFormatter();
|
||||
//options.Filter = filter;
|
||||
options.FlushInterval = TimeSpan.FromSeconds(20);
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
.UseMetricsEndpoints(opt =>
|
||||
{
|
||||
opt.EnvironmentInfoEndpointEnabled = false;
|
||||
opt.MetricsEndpointEnabled = false;
|
||||
opt.MetricsTextEndpointEnabled = false;
|
||||
})
|
||||
.UseMetrics()
|
||||
.UseStartup<Startup>()
|
||||
.ConfigureLogging((context, logging) =>
|
||||
{
|
||||
// clear all previously registered providers
|
||||
//https://stackoverflow.com/a/46336988/8939
|
||||
logging.ClearProviders();
|
||||
})
|
||||
.UseNLog(); // NLog: setup NLog for Dependency injection
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* Dotnet 2.2 buildwebhost will be deprecated in favor of buildhost
|
||||
public static IWebHost BuildWebHost(string[] args, NLog.Logger logger)
|
||||
{
|
||||
logger.Debug("BOOT: building web host");
|
||||
@@ -256,6 +331,7 @@ namespace AyaNova
|
||||
.UseNLog() // NLog: setup NLog for Dependency injection
|
||||
.Build();
|
||||
}
|
||||
*/
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
@@ -438,11 +438,11 @@ namespace AyaNova.Biz
|
||||
#if (DEBUG)
|
||||
//TESTING
|
||||
//make a fake server error for ui testing purposes
|
||||
if (proposedObj.Count == 666)
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Count", "Test field server error");
|
||||
}
|
||||
if (proposedObj.DollarAmount == 666)
|
||||
// if (proposedObj.Count == 666)
|
||||
// {
|
||||
// AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Count", "Test field server error");
|
||||
// }
|
||||
if (proposedObj.DollarAmount == 666.66M)
|
||||
{
|
||||
AddError(ApiErrorCode.INVALID_OPERATION, null, "This is a test of a general server error");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
REM docker start dock-pg10 dock-pgadmin
|
||||
REM docker run --rm --name pg -p 5432:5432 -e POSTGRES_PASSWORD=raven -e POSTGRES_DB=AyaNova -d postgres:latest
|
||||
REM GONE PORTABLE INSTEAD
|
||||
start C:\data\code\PostgreSQLPortable_10.4.1\postgresqlportable.exe
|
||||
start C:\data\code\PostgreSQLPortable_12.0\postgresqlportable.exe
|
||||
|
||||
Reference in New Issue
Block a user