Skip to content

Commit

Permalink
以服务方式运行时,重启服务,否则采取拉起进程的方式;安装dotnet运行时,强行创建软连接,可能Linux有延迟
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 17, 2024
1 parent 3b276eb commit 3998e38
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
23 changes: 20 additions & 3 deletions StarAgent/MyStarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@ protected override void Restart(Upgrade upgrade)
{
this.WriteInfoEvent("Upgrade", "强制更新完成,准备重启后台服务!PID=" + pid);

// 使用外部命令重启服务
var rs = upgrade.Run("StarAgent", "-restart -upgrade");
// 使用外部命令重启服务。执行重启,如果失败,延迟后再次尝试
var rs = upgrade.Run("StarAgent", "-restart -upgrade", 3_000);
if (!rs)
{
var delay = 3_000;
this.WriteInfoEvent("Upgrade", $"拉起新进程失败,延迟{delay}ms后重试");
Thread.Sleep(delay);
rs = upgrade.Run("StarAgent", "-restart -upgrade", 1_000);
}

//!! 这里不需要自杀,外部命令重启服务会结束当前进程
if (rs)
Expand All @@ -101,8 +108,18 @@ protected override void Restart(Upgrade upgrade)
}
else
{
// 重新拉起进程
this.WriteInfoEvent("Upgrade", "强制更新完成,准备拉起新进程!PID=" + pid);

// 重新拉起进程,重启服务,否则采取拉起进程的方式
var rs = upgrade.Run("StarAgent", "-run -upgrade");
if (!rs)
{
var delay = 3_000;
this.WriteInfoEvent("Upgrade", $"拉起新进程失败,延迟{delay}ms后重试");
Thread.Sleep(delay);
rs = upgrade.Run("StarAgent", "-run -upgrade", 1_000);
}

if (rs)
{
Service.StopWork("Upgrade");
Expand Down
1 change: 1 addition & 0 deletions Stardust/Managers/NetRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Boolean InstallOnLinux(String fullFile, String? arg)

// 建立链接
var link = "/usr/bin/dotnet";
if (File.Exists(link)) File.Delete(link);
if (Force && File.Exists(link)) File.Delete(link);

if (!File.Exists(link))
Expand Down

0 comments on commit 3998e38

Please sign in to comment.