From 2f5e237b711b6d0f456a9ba96ca3c8e6e9b3ba02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Mon, 23 Sep 2024 23:52:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=BA=94=E7=94=A8=E5=88=B0?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=97=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E5=BB=B6=E8=BF=9F=E6=97=B6=E9=97=B4=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=BB=9A=E5=8A=A8=E5=8D=87=E7=BA=A7=E3=80=82?= =?UTF-8?q?=20https://github.com/NewLifeX/Stardust/issues/72?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ClientTest/ClientTest.csproj | 2 +- Samples/TestA/TestA.csproj | 2 +- Samples/TestB/TestB.csproj | 2 +- Stardust.Server/Services/NodeService.cs | 1 + Stardust.Server/Services/RegistryService.cs | 1 + Stardust.Server/Stardust.Server.csproj | 4 ++-- .../Areas/Nodes/Controllers/NodeFrameworkController.cs | 6 +++--- .../Areas/Nodes/Controllers/NodeOnlineController.cs | 8 ++++---- .../Areas/Registry/Controllers/AppOnlineController.cs | 4 ++-- Stardust.Web/Services/DeployService.cs | 2 +- Stardust.Web/Stardust.Web.csproj | 4 ++-- Stardust/StarFactory.cs | 8 ++++++-- Stardust/Stardust.csproj | 4 ++-- Test/Test.csproj | 2 +- 14 files changed, 28 insertions(+), 22 deletions(-) diff --git a/ClientTest/ClientTest.csproj b/ClientTest/ClientTest.csproj index 102b17dc..68b59518 100644 --- a/ClientTest/ClientTest.csproj +++ b/ClientTest/ClientTest.csproj @@ -21,7 +21,7 @@ - + diff --git a/Samples/TestA/TestA.csproj b/Samples/TestA/TestA.csproj index 6156c996..7b78a8f3 100644 --- a/Samples/TestA/TestA.csproj +++ b/Samples/TestA/TestA.csproj @@ -18,7 +18,7 @@ - + diff --git a/Samples/TestB/TestB.csproj b/Samples/TestB/TestB.csproj index bad7be88..366deb42 100644 --- a/Samples/TestB/TestB.csproj +++ b/Samples/TestB/TestB.csproj @@ -18,7 +18,7 @@ - + diff --git a/Stardust.Server/Services/NodeService.cs b/Stardust.Server/Services/NodeService.cs index 8d91ec0d..7b724c2b 100644 --- a/Stardust.Server/Services/NodeService.cs +++ b/Stardust.Server/Services/NodeService.cs @@ -735,6 +735,7 @@ public async Task SendCommand(Node node, CommandInModel model, Stri TraceId = DefaultSpan.Current?.TraceId, CreateUser = createUser, }; + if (model.StartTime > 0) cmd.StartTime = DateTime.Now.AddSeconds(model.StartTime); if (model.Expire > 0) cmd.Expire = DateTime.Now.AddSeconds(model.Expire); cmd.Insert(); diff --git a/Stardust.Server/Services/RegistryService.cs b/Stardust.Server/Services/RegistryService.cs index bb475658..df0092c6 100644 --- a/Stardust.Server/Services/RegistryService.cs +++ b/Stardust.Server/Services/RegistryService.cs @@ -456,6 +456,7 @@ public async Task SendCommand(App app, CommandInModel model, String CreateUser = user, }; + if (model.StartTime > 0) cmd.StartTime = DateTime.Now.AddSeconds(model.StartTime); if (model.Expire > 0) cmd.Expire = DateTime.Now.AddSeconds(model.Expire); cmd.Insert(); diff --git a/Stardust.Server/Stardust.Server.csproj b/Stardust.Server/Stardust.Server.csproj index 906d2d45..dbcd59f4 100644 --- a/Stardust.Server/Stardust.Server.csproj +++ b/Stardust.Server/Stardust.Server.csproj @@ -45,8 +45,8 @@ - - + + diff --git a/Stardust.Web/Areas/Nodes/Controllers/NodeFrameworkController.cs b/Stardust.Web/Areas/Nodes/Controllers/NodeFrameworkController.cs index 2d3af567..f8a83f10 100644 --- a/Stardust.Web/Areas/Nodes/Controllers/NodeFrameworkController.cs +++ b/Stardust.Web/Areas/Nodes/Controllers/NodeFrameworkController.cs @@ -84,7 +84,7 @@ public async Task InstallFramework(String ver, String baseUrl) var node = bf.FindByKey(item.ToInt()); if (node != null && !node.Code.IsNullOrEmpty()) { - ts.Add(_starFactory.SendNodeCommand(node.Code, "framework/install", args, 30 * 24 * 3600, 0)); + ts.Add(_starFactory.SendNodeCommand(node.Code, "framework/install", args, 0, 30 * 24 * 3600, 0)); } } @@ -102,7 +102,7 @@ public async Task UninstallFramework(String ver) if (ver.IsNullOrEmpty()) throw new ArgumentNullException(nameof(ver)); ver = ver.Trim(); - + var bf = new BatchFinder(); bf.Add(SelectKeys.Select(e => e.ToInt())); @@ -115,7 +115,7 @@ public async Task UninstallFramework(String ver) var node = bf.FindByKey(item.ToInt()); if (node != null && !node.Code.IsNullOrEmpty()) { - ts.Add(_starFactory.SendNodeCommand(node.Code, "framework/uninstall", args, 30 * 24 * 3600, 0)); + ts.Add(_starFactory.SendNodeCommand(node.Code, "framework/uninstall", args, 0, 30 * 24 * 3600, 0)); } } diff --git a/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs b/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs index 78ec4e9c..527eaec3 100644 --- a/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs +++ b/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs @@ -125,7 +125,7 @@ public async Task CheckUpgrade() var online = NodeOnline.FindById(item.ToInt()); if (online?.Node != null) { - ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/upgrade", null, 600, 0)); + ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/upgrade", null, 0, 600, 0)); } } @@ -144,7 +144,7 @@ public async Task Restart() var online = NodeOnline.FindById(item.ToInt()); if (online?.Node != null) { - ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/restart", null, 600, 0)); + ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/restart", null, 0, 600, 0)); } } @@ -163,7 +163,7 @@ public async Task Reboot() var online = NodeOnline.FindById(item.ToInt()); if (online?.Node != null) { - ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/reboot", null, 600, 0)); + ts.Add(_starFactory.SendNodeCommand(online.Node.Code, "node/reboot", null, 0, 600, 0)); } } @@ -185,7 +185,7 @@ public async Task Execute(String command, String argument) var online = NodeOnline.FindById(item.ToInt()); if (online != null && online.Node != null) { - ts.Add(_starFactory.SendNodeCommand(online.Node.Code, command, argument, 30, 0)); + ts.Add(_starFactory.SendNodeCommand(online.Node.Code, command, argument, 0, 30, 0)); } } diff --git a/Stardust.Web/Areas/Registry/Controllers/AppOnlineController.cs b/Stardust.Web/Areas/Registry/Controllers/AppOnlineController.cs index ed097960..a52b57e9 100644 --- a/Stardust.Web/Areas/Registry/Controllers/AppOnlineController.cs +++ b/Stardust.Web/Areas/Registry/Controllers/AppOnlineController.cs @@ -127,7 +127,7 @@ public async Task Execute(String command, String argument) var online = AppOnline.FindById(item.ToInt()); if (online != null && online.App != null) { - ts.Add(_starFactory.SendAppCommand(online.App.Name, command, argument, 30, 0)); + ts.Add(_starFactory.SendAppCommand(online.App.Name, command, argument, 0, 30, 0)); } } @@ -146,7 +146,7 @@ public async Task FreeMemory() var online = AppOnline.FindById(item.ToInt()); if (online != null && online.App != null) { - ts.Add(_starFactory.SendAppCommand(online.App.Name, "app/freeMemory", null, 30, 0)); + ts.Add(_starFactory.SendAppCommand(online.App.Name, "app/freeMemory", null, 0, 30, 0)); } } diff --git a/Stardust.Web/Services/DeployService.cs b/Stardust.Web/Services/DeployService.cs index b4e3e681..453814db 100644 --- a/Stardust.Web/Services/DeployService.cs +++ b/Stardust.Web/Services/DeployService.cs @@ -56,7 +56,7 @@ public async Task Control(AppDeploy app, AppDeployNode deployNode, String action var args = new { deployNode.Id, deployNode.DeployName, AppName = deployNode.DeployName }.ToJson(); msg = args; - await _starFactory.SendNodeCommand(deployNode.Node.Code, action, args, 60, timeout); + await _starFactory.SendNodeCommand(deployNode.Node.Code, action, args, deployNode.Delay, 60, timeout); } catch (Exception ex) { diff --git a/Stardust.Web/Stardust.Web.csproj b/Stardust.Web/Stardust.Web.csproj index 5962686a..73cc2e44 100644 --- a/Stardust.Web/Stardust.Web.csproj +++ b/Stardust.Web/Stardust.Web.csproj @@ -52,8 +52,8 @@ - - + + diff --git a/Stardust/StarFactory.cs b/Stardust/StarFactory.cs index 199523c5..47c59997 100644 --- a/Stardust/StarFactory.cs +++ b/Stardust/StarFactory.cs @@ -453,10 +453,11 @@ public IRegistry? Service /// /// /// + /// /// /// /// - public async Task SendNodeCommand(String nodeCode, String command, String? argument = null, Int32 expire = 3600, Int32 timeout = 5) + public async Task SendNodeCommand(String nodeCode, String command, String? argument = null, Int32 startTime = 0, Int32 expire = 3600, Int32 timeout = 5) { if (!Valid()) return -1; @@ -465,6 +466,7 @@ public async Task SendNodeCommand(String nodeCode, String command, String Code = nodeCode, Command = command, Argument = argument, + StartTime = startTime, Expire = expire, Timeout = timeout }); @@ -474,10 +476,11 @@ public async Task SendNodeCommand(String nodeCode, String command, String /// /// /// + /// /// /// /// - public async Task SendAppCommand(String appId, String command, String? argument = null, Int32 expire = 3600, Int32 timeout = 5) + public async Task SendAppCommand(String appId, String command, String? argument = null, Int32 startTime = 0, Int32 expire = 3600, Int32 timeout = 5) { if (!Valid()) return -1; @@ -486,6 +489,7 @@ public async Task SendAppCommand(String appId, String command, String? ar Code = appId, Command = command, Argument = argument, + StartTime = startTime, Expire = expire, Timeout = timeout }); diff --git a/Stardust/Stardust.csproj b/Stardust/Stardust.csproj index 07d4cbef..222a88c3 100644 --- a/Stardust/Stardust.csproj +++ b/Stardust/Stardust.csproj @@ -112,10 +112,10 @@ - + - + diff --git a/Test/Test.csproj b/Test/Test.csproj index b9a5643d..7f6b4c87 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -30,7 +30,7 @@ - +