From 485cb24a7fd3912df20f28e783aa7aca87ec2ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E4=BA=BA=E6=98=93?= Date: Fri, 5 Jul 2024 16:58:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20AutoStop=20=E5=92=8C=20Rel?= =?UTF-8?q?oadOnChange=20=E5=8A=9F=E8=83=BD=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 Model.xml 中添加了 AutoStop 和 ReloadOnChange 列。 在 Stardust.htm 中添加了相应的表格行。 在 ServiceController.cs 中更新 MonitorFileChange 方法, 增加了对 ReloadOnChange 的判断。 --- Stardust.Data/Deployment/Model.xml | 2 ++ Stardust.Data/Deployment/Stardust.htm | 22 +++++++++++++ ...24\347\224\250\351\203\250\347\275\262.cs" | 32 +++++++++++++++++++ Stardust/Managers/ServiceController.cs | 2 ++ 4 files changed, 58 insertions(+) diff --git a/Stardust.Data/Deployment/Model.xml b/Stardust.Data/Deployment/Model.xml index 23a2cbf0..2b1799d8 100644 --- a/Stardust.Data/Deployment/Model.xml +++ b/Stardust.Data/Deployment/Model.xml @@ -63,6 +63,8 @@ + + diff --git a/Stardust.Data/Deployment/Stardust.htm b/Stardust.Data/Deployment/Stardust.htm index 4db3246a..81c40af3 100644 --- a/Stardust.Data/Deployment/Stardust.htm +++ b/Stardust.Data/Deployment/Stardust.htm @@ -291,6 +291,28 @@

应用部署(AppDeploy)

0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip + + AutoStop + 是否自动停止 + Boolean + + + + N + 随着宿主的退出,同时停止该应用进程 + + + + ReloadOnChange + 检测文件变动 + Boolean + + + + N + 当文件发生改变时,自动重启应用 + + CreateUserId 创建者 diff --git "a/Stardust.Data/Deployment/\345\272\224\347\224\250\351\203\250\347\275\262.cs" "b/Stardust.Data/Deployment/\345\272\224\347\224\250\351\203\250\347\275\262.cs" index 6ee0843b..74f71ab0 100644 --- "a/Stardust.Data/Deployment/\345\272\224\347\224\250\351\203\250\347\275\262.cs" +++ "b/Stardust.Data/Deployment/\345\272\224\347\224\250\351\203\250\347\275\262.cs" @@ -210,6 +210,22 @@ public partial class AppDeploy [BindColumn("Mode", "工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip", "")] public Stardust.Models.ServiceModes Mode { get => _Mode; set { if (OnPropertyChanging("Mode", value)) { _Mode = value; OnPropertyChanged("Mode"); } } } + private Boolean _AutoStop; + /// 是否自动停止。随着宿主的退出,同时停止该应用进程 + [DisplayName("是否自动停止")] + [Description("是否自动停止。随着宿主的退出,同时停止该应用进程")] + [DataObjectField(false, false, false, 0)] + [BindColumn("AutoStop", "是否自动停止。随着宿主的退出,同时停止该应用进程", "")] + public Boolean AutoStop { get => _AutoStop; set { if (OnPropertyChanging("AutoStop", value)) { _AutoStop = value; OnPropertyChanged("AutoStop"); } } } + + private Boolean _ReloadOnChange; + /// 检测文件变动。当文件发生改变时,自动重启应用 + [DisplayName("检测文件变动")] + [Description("检测文件变动。当文件发生改变时,自动重启应用")] + [DataObjectField(false, false, false, 0)] + [BindColumn("ReloadOnChange", "检测文件变动。当文件发生改变时,自动重启应用", "")] + public Boolean ReloadOnChange { get => _ReloadOnChange; set { if (OnPropertyChanging("ReloadOnChange", value)) { _ReloadOnChange = value; OnPropertyChanged("ReloadOnChange"); } } } + private Int32 _CreateUserId; /// 创建者 [Category("扩展")] @@ -304,6 +320,8 @@ public override Object this[String name] "UserName" => _UserName, "MaxMemory" => _MaxMemory, "Mode" => _Mode, + "AutoStop" => _AutoStop, + "ReloadOnChange" => _ReloadOnChange, "CreateUserId" => _CreateUserId, "CreateTime" => _CreateTime, "CreateIP" => _CreateIP, @@ -339,6 +357,8 @@ public override Object this[String name] case "UserName": _UserName = Convert.ToString(value); break; case "MaxMemory": _MaxMemory = value.ToInt(); break; case "Mode": _Mode = (Stardust.Models.ServiceModes)value.ToInt(); break; + case "AutoStop": _AutoStop = value.ToBoolean(); break; + case "ReloadOnChange": _ReloadOnChange = value.ToBoolean(); break; case "CreateUserId": _CreateUserId = value.ToInt(); break; case "CreateTime": _CreateTime = value.ToDateTime(); break; case "CreateIP": _CreateIP = Convert.ToString(value); break; @@ -433,6 +453,12 @@ public partial class _ /// 工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip public static readonly Field Mode = FindByName("Mode"); + /// 是否自动停止。随着宿主的退出,同时停止该应用进程 + public static readonly Field AutoStop = FindByName("AutoStop"); + + /// 检测文件变动。当文件发生改变时,自动重启应用 + public static readonly Field ReloadOnChange = FindByName("ReloadOnChange"); + /// 创建者 public static readonly Field CreateUserId = FindByName("CreateUserId"); @@ -526,6 +552,12 @@ public partial class __ /// 工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip public const String Mode = "Mode"; + /// 是否自动停止。随着宿主的退出,同时停止该应用进程 + public const String AutoStop = "AutoStop"; + + /// 检测文件变动。当文件发生改变时,自动重启应用 + public const String ReloadOnChange = "ReloadOnChange"; + /// 创建者 public const String CreateUserId = "CreateUserId"; diff --git a/Stardust/Managers/ServiceController.cs b/Stardust/Managers/ServiceController.cs index 2d50500f..4e0e231a 100644 --- a/Stardust/Managers/ServiceController.cs +++ b/Stardust/Managers/ServiceController.cs @@ -677,6 +677,8 @@ private void StartMonitor() private void MonitorFileChange(Object? state) { + if (Info?.ReloadOnChange == false) return; + var first = _files.Count == 0; var changed = "";