Last active
June 11, 2021 16:31
Revisions
-
yzorg revised this gist
Jun 11, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) return Host.CreateDefaultBuilder() .ConfigureAppConfiguration((hostingContext, config) => { config.AddKeyPerFile(directoryPath: "/app/secrets/shared", optional: true); config.AddKeyPerFile(directoryPath: "/app/secrets/namespace", optional: true); config.AddCommandLine(args, switchMappings); -
yzorg created this gist
Jun 11, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Middle.MyApp { class Program { static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) { var switchMappings = new Dictionary<string, string>() { { "-s", "Start" }, { "--start", "Start" } }; return Host.CreateDefaultBuilder() .ConfigureAppConfiguration((hostingContext, config) => { config.AddKeyPerFile(directoryPath: "/app/secrets/project", optional: true); config.AddKeyPerFile(directoryPath: "/app/secrets/namespace", optional: true); config.AddCommandLine(args, switchMappings); }) //.ConfigureLogging(opt => { opt.AddConsole(c => { c.TimestampFormat = "[HH:mm:ss] "; }); }) // CORE31 .ConfigureLogging(opt => { opt.AddSimpleConsole(consoleOpt => { consoleOpt.TimestampFormat = "yyyy-MM-ddTHH:mm:ss.ff "; //consoleOpt.UseUtcTimestamp = true; // not needed, k8s node local time will be UTC, and I'd prefer not to see UTC when running on Win10/WSL }); }) .ConfigureServices((hostContext, services) => { new Startup(hostContext.Configuration) .ConfigureServices(services); }); } public record Startup(IConfiguration Configuration) { public void ConfigureServices(IServiceCollection services) { services.Configure<LoaderOptions>(Configuration); services.AddDbContextFactory<Models.AppSqlContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("AppSql"), sqlOptions => { sqlOptions.EnableRetryOnFailure(3); }); }); services.AddHostedService<Worker>(); } } }