Browse Source
Use the new hosting model (remove the Startup class) in all applications.pull/73/head
committed by
GitHub
21 changed files with 287 additions and 601 deletions
@ -1,46 +1,36 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
|
|||
namespace EShopOnAbp.AuthServer |
|||
namespace EShopOnAbp.AuthServer; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpAuthServerModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.AuthServer |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<EShopOnAbpAuthServerModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,52 +1,36 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
|
|||
namespace EShopOnAbp.PublicWeb |
|||
namespace EShopOnAbp.PublicWeb; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpPublicWebModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
namespace EShopOnAbp.PublicWeb |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<EShopOnAbpPublicWebModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,46 +1,36 @@ |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway |
|||
namespace EShopOnAbp.WebPublicGateway; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebPublicGatewayModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true, reloadOnChange:true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.WebPublicGateway |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<EShopOnAbpWebPublicGatewayModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,46 +1,36 @@ |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
|
|||
namespace EShopOnAbp.WebGateway |
|||
namespace EShopOnAbp.WebGateway; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper.BuildApplicationAsync<EShopOnAbpWebGatewayModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.WebGateway |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<EShopOnAbpWebGatewayModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,46 +1,37 @@ |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
|
|||
namespace EShopOnAbp.AdministrationService |
|||
namespace EShopOnAbp.AdministrationService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<AdministrationServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.AdministrationService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<AdministrationServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,56 +1,37 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace EShopOnAbp.BasketService |
|||
namespace EShopOnAbp.BasketService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static int Main(string[] args) |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
#if DEBUG
|
|||
.MinimumLevel.Debug() |
|||
#else
|
|||
.MinimumLevel.Information() |
|||
#endif
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
#if DEBUG
|
|||
.WriteTo.Async(c => c.Console()) |
|||
#endif
|
|||
.CreateLogger(); |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<BasketServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting EShopOnAbp.BasketService.HttpApi.Host."); |
|||
CreateHostBuilder(args).Build().Run(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace EShopOnAbp.BasketService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<BasketServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,56 +1,37 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace EShopOnAbp.CatalogService |
|||
namespace EShopOnAbp.CatalogService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static int Main(string[] args) |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
#if DEBUG
|
|||
.MinimumLevel.Debug() |
|||
#else
|
|||
.MinimumLevel.Information() |
|||
#endif
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
#if DEBUG
|
|||
.WriteTo.Async(c => c.Console()) |
|||
#endif
|
|||
.CreateLogger(); |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<CatalogServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting EShopOnAbp.CatalogService.HttpApi.Host."); |
|||
CreateHostBuilder(args).Build().Run(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace EShopOnAbp.CatalogService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<CatalogServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,46 +1,37 @@ |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
|
|||
namespace EShopOnAbp.IdentityService |
|||
namespace EShopOnAbp.IdentityService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
try |
|||
{ |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<IdentityServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureAppConfiguration(build => |
|||
{ |
|||
build.AddJsonFile("appsettings.secrets.json", optional: true); |
|||
}) |
|||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace EShopOnAbp.IdentityService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<IdentityServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,56 +1,37 @@ |
|||
using System; |
|||
using System.IO; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace EShopOnAbp.OrderingService |
|||
namespace EShopOnAbp.OrderingService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static int Main(string[] args) |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
#if DEBUG
|
|||
.MinimumLevel.Debug() |
|||
#else
|
|||
.MinimumLevel.Information() |
|||
#endif
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
#if DEBUG
|
|||
.WriteTo.Async(c => c.Console()) |
|||
#endif
|
|||
.CreateLogger(); |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<OrderingServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting web host."); |
|||
CreateHostBuilder(args).Build().Run(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace EShopOnAbp.OrderingService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<OrderingServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,56 +1,37 @@ |
|||
using System; |
|||
using System.IO; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace EShopOnAbp.PaymentService |
|||
namespace EShopOnAbp.PaymentService; |
|||
|
|||
public class Program |
|||
{ |
|||
public class Program |
|||
public static async Task<int> Main(string[] args) |
|||
{ |
|||
public static int Main(string[] args) |
|||
var assemblyName = typeof(Program).Assembly.GetName().Name; |
|||
|
|||
SerilogConfigurationHelper.Configure(assemblyName); |
|||
|
|||
try |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
#if DEBUG
|
|||
.MinimumLevel.Debug() |
|||
#else
|
|||
.MinimumLevel.Information() |
|||
#endif
|
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
#if DEBUG
|
|||
.WriteTo.Async(c => c.Console()) |
|||
#endif
|
|||
.CreateLogger(); |
|||
Log.Information($"Starting {assemblyName}."); |
|||
var app = await ApplicationBuilderHelper |
|||
.BuildApplicationAsync<PaymentServiceHttpApiHostModule>(args); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
|
|||
try |
|||
{ |
|||
Log.Information("Starting web host."); |
|||
CreateHostBuilder(args).Build().Run(); |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, "Host terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
return 0; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!"); |
|||
return 1; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
|
|||
internal static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace EShopOnAbp.PaymentService |
|||
{ |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<PaymentServiceHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace EShopOnAbp.Shared.Hosting.AspNetCore; |
|||
|
|||
public static class ApplicationBuilderHelper |
|||
{ |
|||
public static async Task<WebApplication> BuildApplicationAsync<TStartupModule>(string[] args) |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host |
|||
.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.UseSerilog(); |
|||
|
|||
await builder.AddApplicationAsync<TStartupModule>(); |
|||
return builder.Build(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue