Browse Source

feat: 更新 PostgreSQL 配置

pull/1048/head
feijie 1 year ago
parent
commit
cd136b1ab6
  1. 12
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json
  2. 15
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/FodyWeavers.xsd
  3. 12
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs
  4. 168
      aspnet-core/services/LY.MicroService.Applications.Single/Program.cs
  5. 11
      aspnet-core/services/LY.MicroService.Applications.Single/Properties/launchSettings.json
  6. 23
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.PostgreSql.json

12
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json

@ -48,9 +48,9 @@
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"PostgreSql": {
"Enabled": true
}
}
@ -71,18 +71,18 @@
"PublishWebhook": true,
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"PostgreSql": {
"Enabled": true
}
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"PostgreSql": {
"Enabled": true
}
}

15
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/FodyWeavers.xsd

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This is a partial XSD schema. For brevity, only essential elements are included -->
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
@ -12,14 +12,19 @@
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>Use to enforce assembly verification.</xs:documentation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored.</xs:documentation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
</xs:schema>

12
aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs

@ -316,14 +316,18 @@ namespace LY.MicroService.Applications.Single;
typeof(AbpAccountTemplatesModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpCachingStackExchangeRedisModule),
#if POSTGRESQL
// typeof(AbpElsaModule),
// typeof(AbpElsaServerModule),
// typeof(AbpElsaActivitiesModule),
// typeof(AbpElsaEntityFrameworkCoreModule),
// typeof(AbpElsaEntityFrameworkCorePostgreSqlModule),
#else
typeof(AbpElsaModule),
typeof(AbpElsaServerModule),
typeof(AbpElsaActivitiesModule),
typeof(AbpElsaEntityFrameworkCoreModule),
#if POSTGRESQL
typeof(AbpElsaEntityFrameworkCorePostgreSqlModule),
#else
typeof(AbpElsaEntityFrameworkCoreMySqlModule),
#endif

168
aspnet-core/services/LY.MicroService.Applications.Single/Program.cs

@ -1,86 +1,82 @@
using LINGYUN.Abp.Identity.Session.AspNetCore;
using LY.MicroService.Applications.Single;
using Microsoft.AspNetCore.Cors;
using Serilog;
using Volo.Abp.IO;
using Volo.Abp.Modularity.PlugIns;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy
.WithOrigins(
builder.Configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.WithAbpWrapExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog((context, provider, config) =>
{
config.ReadFrom.Configuration(context.Configuration);
});
await builder.AddApplicationAsync<MicroServiceApplicationsSingleModule>(options =>
{
MicroServiceApplicationsSingleModule.ApplicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME")
?? MicroServiceApplicationsSingleModule.ApplicationName;
options.ApplicationName = MicroServiceApplicationsSingleModule.ApplicationName;
// 从环境变量取用户机密配置, 适用于容器测试
options.Configuration.UserSecretsId = Environment.GetEnvironmentVariable("APPLICATION_USER_SECRETS_ID");
// 如果容器没有指定用户机密, 从项目读取
options.Configuration.UserSecretsAssembly = typeof(MicroServiceApplicationsSingleModule).Assembly;
// 搜索 Modules 目录下所有文件作为插件
// 取消显示引用所有其他项目的模块,改为通过插件的形式引用
var pluginFolder = Path.Combine(
Directory.GetCurrentDirectory(), "Modules");
DirectoryHelper.CreateIfNotExists(pluginFolder);
options.PlugInSources.AddFolder(
pluginFolder,
SearchOption.AllDirectories);
});
var app = builder.Build();
await app.InitializeApplicationAsync();
app.UseForwardedHeaders();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// app.UseAbpExceptionHandling();
app.UseCookiePolicy();
app.UseMapRequestLocalization();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseMultiTenancy();
app.UseUnitOfWork();
app.UseAbpOpenIddictValidation();
app.UseAbpSession();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support App API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
await app.RunAsync();
using LINGYUN.Abp.Identity.Session.AspNetCore;
using LY.MicroService.Applications.Single;
using Microsoft.AspNetCore.Cors;
using Serilog;
using Volo.Abp.IO;
using Volo.Abp.Modularity.PlugIns;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy
.WithOrigins(
builder.Configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.WithAbpWrapExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog((context, provider, config) =>
{
config.ReadFrom.Configuration(context.Configuration);
});
await builder.AddApplicationAsync<MicroServiceApplicationsSingleModule>(options =>
{
MicroServiceApplicationsSingleModule.ApplicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME")
?? MicroServiceApplicationsSingleModule.ApplicationName;
options.ApplicationName = MicroServiceApplicationsSingleModule.ApplicationName;
options.Configuration.UserSecretsId = Environment.GetEnvironmentVariable("APPLICATION_USER_SECRETS_ID");
options.Configuration.UserSecretsAssembly = typeof(MicroServiceApplicationsSingleModule).Assembly;
var pluginFolder = Path.Combine(
Directory.GetCurrentDirectory(), "Modules");
DirectoryHelper.CreateIfNotExists(pluginFolder);
options.PlugInSources.AddFolder(
pluginFolder,
SearchOption.AllDirectories);
});
var app = builder.Build();
await app.InitializeApplicationAsync();
app.UseForwardedHeaders();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// app.UseAbpExceptionHandling();
app.UseCookiePolicy();
app.UseMapRequestLocalization();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseMultiTenancy();
app.UseUnitOfWork();
app.UseAbpOpenIddictValidation();
app.UseAbpSession();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support App API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
await app.RunAsync();

11
aspnet-core/services/LY.MicroService.Applications.Single/Properties/launchSettings.json

@ -17,11 +17,20 @@
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"LY.MicroService.Applications.Single.Development": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://0.0.0.0:30000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"LY.MicroService.Applications.Single.PostgreSQL": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://0.0.0.0:30001",
"applicationUrl": "http://0.0.0.0:30000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "PostgreSQL"
}

23
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.PostgreSql.json

@ -47,8 +47,8 @@
"Elsa": {
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"Enabled": false,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
@ -70,8 +70,8 @@
"IM": true,
"PublishWebhook": true,
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"Enabled": false,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
@ -79,8 +79,8 @@
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"Enabled": false,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
@ -93,16 +93,17 @@
}
},
"Quartz": {
"UsePersistentStore": true,
"UsePersistentStore": false,
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate, Quartz",
"quartz.jobStore.useProperties": "true",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"quartz.dataSource.tkm.provider": "Npgsql",
"quartz.dataSource.tkm.connectionStringName": "Default",
"quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json",
"quartz.dataSource.tkm.connectionStringName": "TaskManagement"
"quartz.serializer.type": "json"
}
},
"Redis": {

Loading…
Cancel
Save