Skip to content

Commit

Permalink
发布应用到节点时,支持设定延迟时间,以实现滚动升级。
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Sep 23, 2024
1 parent e4e9ded commit 2f5e237
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ClientTest/ClientTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.917-beta0105" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.921-beta0817" />
<PackageReference Include="NewLife.UnitTest" Version="1.0.2024.102-beta0146" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down
2 changes: 1 addition & 1 deletion Samples/TestA/TestA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.917-beta0004" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.923-beta0014" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/TestB/TestB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.917-beta0004" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.923-beta0014" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Stardust.Server/Services/NodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ public async Task<NodeCommand> 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();

Expand Down
1 change: 1 addition & 0 deletions Stardust.Server/Services/RegistryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ public async Task<AppCommand> 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();

Expand Down
4 changes: 2 additions & 2 deletions Stardust.Server/Stardust.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

<ItemGroup>
<PackageReference Include="NewLife.IP" Version="2.2.2024.902" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.917-beta0105" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.914-beta0002" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.921-beta0817" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.923-beta0435" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task<ActionResult> 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));

}
}
Expand All @@ -102,7 +102,7 @@ public async Task<ActionResult> UninstallFramework(String ver)
if (ver.IsNullOrEmpty()) throw new ArgumentNullException(nameof(ver));

ver = ver.Trim();

var bf = new BatchFinder<Int32, Node>();
bf.Add(SelectKeys.Select(e => e.ToInt()));

Expand All @@ -115,7 +115,7 @@ public async Task<ActionResult> 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));

}
}
Expand Down
8 changes: 4 additions & 4 deletions Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public async Task<ActionResult> 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));
}
}

Expand All @@ -144,7 +144,7 @@ public async Task<ActionResult> 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));
}
}

Expand All @@ -163,7 +163,7 @@ public async Task<ActionResult> 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));
}
}

Expand All @@ -185,7 +185,7 @@ public async Task<ActionResult> 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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task<ActionResult> 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));
}
}

Expand All @@ -146,7 +146,7 @@ public async Task<ActionResult> 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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Stardust.Web/Services/DeployService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Stardust.Web/Stardust.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<ItemGroup>
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.902" />
<PackageReference Include="NewLife.IP" Version="2.2.2024.902" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.917-beta0105" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.914-beta0002" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.921-beta0817" />
<PackageReference Include="NewLife.Remoting.Extensions" Version="3.0.2024.923-beta0435" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions Stardust/StarFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,11 @@ public IRegistry? Service
/// <param name="nodeCode"></param>
/// <param name="command"></param>
/// <param name="argument"></param>
/// <param name="startTime"></param>
/// <param name="expire"></param>
/// <param name="timeout"></param>
/// <returns></returns>
public async Task<Int32> SendNodeCommand(String nodeCode, String command, String? argument = null, Int32 expire = 3600, Int32 timeout = 5)
public async Task<Int32> SendNodeCommand(String nodeCode, String command, String? argument = null, Int32 startTime = 0, Int32 expire = 3600, Int32 timeout = 5)
{
if (!Valid()) return -1;

Expand All @@ -465,6 +466,7 @@ public async Task<Int32> SendNodeCommand(String nodeCode, String command, String
Code = nodeCode,
Command = command,
Argument = argument,
StartTime = startTime,
Expire = expire,
Timeout = timeout
});
Expand All @@ -474,10 +476,11 @@ public async Task<Int32> SendNodeCommand(String nodeCode, String command, String
/// <param name="appId"></param>
/// <param name="command"></param>
/// <param name="argument"></param>
/// <param name="startTime"></param>
/// <param name="expire"></param>
/// <param name="timeout"></param>
/// <returns></returns>
public async Task<Int32> SendAppCommand(String appId, String command, String? argument = null, Int32 expire = 3600, Int32 timeout = 5)
public async Task<Int32> SendAppCommand(String appId, String command, String? argument = null, Int32 startTime = 0, Int32 expire = 3600, Int32 timeout = 5)
{
if (!Valid()) return -1;

Expand All @@ -486,6 +489,7 @@ public async Task<Int32> SendAppCommand(String appId, String command, String? ar
Code = appId,
Command = command,
Argument = argument,
StartTime = startTime,
Expire = expire,
Timeout = timeout
});
Expand Down
4 changes: 2 additions & 2 deletions Stardust/Stardust.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NewLife.Remoting" Version="3.1.2024.914-beta0002" />
<PackageReference Include="NewLife.Remoting" Version="3.1.2024.923-beta0435" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="11.0.2024.917-beta0004" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.923-beta0014" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.917-beta0004" />
<PackageReference Include="NewLife.Core" Version="11.0.2024.923-beta0014" />
<PackageReference Include="SSH.NET" Version="2024.1.0" />
</ItemGroup>

Expand Down

0 comments on commit 2f5e237

Please sign in to comment.