This commit is contained in:
Diego
2025-09-16 19:13:19 +08:00
parent 61f13cef3c
commit 0e3898218b
15 changed files with 51 additions and 22 deletions

View File

@@ -106,6 +106,17 @@ public static class Runtime
#if NET6_0_OR_GREATER
public static Boolean IsSystemd
{
get
{
var id = Environment.GetEnvironmentVariable("INVOCATION_ID");
return !string.IsNullOrEmpty(id);
}
}
public static Boolean? isLegacyWindows;
/// <summary>

View File

@@ -21,6 +21,7 @@ public class Setting : Config<Setting>
#region
/// <summary>是否启用全局调试。默认启用</summary>
[Description("全局调试。XTrace.Debug")]
[XmlIgnore, IgnoreDataMember]
public Boolean Debug { get; set; } = true;
/// <summary>日志等级只输出大于等于该级别的日志All/Debug/Info/Warn/Error/Fatal默认Info</summary>
@@ -30,6 +31,7 @@ public class Setting : Config<Setting>
/// <summary>文件日志目录。默认Log子目录</summary>
[Description("文件日志目录。默认Log子目录")]
[XmlIgnore, IgnoreDataMember]
public String LogPath { get; set; } = "Logs/XLog";
/// <summary>日志文件上限。超过上限后拆分新日志文件默认5MB0表示不限制大小</summary>
@@ -42,6 +44,7 @@ public class Setting : Config<Setting>
/// <summary>日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log</summary>
[Description("日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log")]
[XmlIgnore, IgnoreDataMember]
public String LogFileFormat { get; set; } = "{0:yyyy_MM_dd}.log";
/// <summary>日志行格式。默认Time|ThreadId|Kind|Name|Message还支持Level</summary>

View File

@@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.11.43</PluginVersion>
<ProPluginVersion>10.11.43</ProPluginVersion>
<DefaultVersion>10.11.43</DefaultVersion>
<PluginVersion>10.11.44</PluginVersion>
<ProPluginVersion>10.11.44</ProPluginVersion>
<DefaultVersion>10.11.44</DefaultVersion>
<AuthenticationVersion>10.11.5</AuthenticationVersion>
<SourceGeneratorVersion>10.11.4</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version>

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes" Version="1.5.376.244" />
</ItemGroup>

View File

@@ -39,7 +39,7 @@ public class RealDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -85,7 +85,6 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
DynamicSQLBase? hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -112,7 +112,6 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -69,13 +69,13 @@ public class SqlDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 实时表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRealTable { get; set; }
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -102,7 +102,6 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -1,7 +1,4 @@
{
"Debug": "true",
"LogPath": "Logs/XLog",
"LogFileMaxBytes": "5", //5mb最大日志文件
"LogFileBackups": "50", //50个日志文件
"LogFileFormat": "{0:yyyy_MM_dd}.log"
"LogFileBackups": "50" //50个日志文件
}

View File

@@ -36,6 +36,7 @@ public class Program
ClaimConst.Scheme = $"{typeof(Program).Assembly.GetName().Name}{SchemeHelper.GetOrCreate()}";
Runtime.CreateConfigOnMissing = true;
#region Logo
Console.Write(Environment.NewLine);
@@ -72,8 +73,17 @@ public class Program
if (Runtime.IsLegacyWindows)
builder.Logging.ClearProviders(); //去除默认的事件日志提供者,某些情况下会日志输出异常,导致程序崩溃
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning);
}
if (!builder.Environment.IsDevelopment())
{
builder.Services.AddResponseCompression(
@@ -108,6 +118,8 @@ public class Program
#endif
ReflectionInoHelper.RemoveAllCache();
InstanceFactory.RemoveCache();
})
@@ -136,6 +148,12 @@ public class Program
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.ConfigureLogging(a => a.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning));
}
// 设置接口超时时间和上传大小-Kestrel
builder.ConfigureKestrel(u =>
{
@@ -144,11 +162,7 @@ public class Program
u.Limits.MaxRequestBodySize = null;
}).UseKestrel().Configure(app =>
{
// ✅ 最小中间件
app.Run(context =>
{
return context.Response.WriteAsync("web is disable");
});
app.Run(context => context.Response.WriteAsync("web is disable"));
});
})
.Configure(app =>

View File

@@ -73,7 +73,6 @@ public class Startup : AppStartup
services.AddRazorPages();
services.AddMvcFilter<RequestAuditFilter>();
services.AddControllers()

View File

@@ -1,5 +1,5 @@
#docker run -d --name tg --restart always -p 127.0.0.1:5000:5000 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
#docker run -d --log-driver json-file --log-opt max-size=50m --log-opt max-file=5 --name tg --restart always -p 127.0.0.1:5000:5000 -p 502:502 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
version: "latest" # Docker Compose 配置版本

View File

@@ -25,6 +25,14 @@ Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
# 文件配置
# [Journal]
# SystemMaxUse=200M # 日志最大占用200MB磁盘空间
# SystemMaxFileSize=50M # 单个日志文件最大50MB
# MaxRetentionSec=1month # 日志只保留1个月
# RuntimeMaxUse=100M # 内存中最多缓存100MB日志
# 加载服务配置文件
# systemctl daemon-reload