Skip to content

Commit

Permalink
调整 MyStarClient 日志信息,优化 MyService 参数
Browse files Browse the repository at this point in the history
在 `MyStarClient.cs` 文件中,删除了注释 `// 重新拉起进程`,并调整了日志信息的内容。

在 `Program.cs` 文件中,增加了 `using NewLife.Agent.Models;` 和 `using ServiceModel = NewLife.Agent.Models.ServiceModel;` 的引用。

在 `Program.cs` 文件中,修改了 `MyService` 类的代码,将 `Host.Install` 方法的参数从多个独立参数改为一个 `ServiceModel` 对象。
  • Loading branch information
猿人易 committed Dec 4, 2024
1 parent 53c13db commit c57f84e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion StarAgent/MyStarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ protected override void Restart(Upgrade upgrade)
}
else
{
// 重新拉起进程
this.WriteInfoEvent("Upgrade", "强制更新完成,准备拉起新进程!PID=" + pid);

// 重新拉起进程,重启服务,否则采取拉起进程的方式
Expand Down
13 changes: 12 additions & 1 deletion StarAgent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Reflection;
using NewLife;
using NewLife.Agent;
using NewLife.Agent.Models;
using NewLife.Log;
using NewLife.Model;
using NewLife.Reflection;
Expand All @@ -14,6 +15,7 @@
using Stardust.Models;
using Stardust.Plugins;
using IHost = NewLife.Agent.IHost;
using ServiceModel = NewLife.Agent.Models.ServiceModel;

namespace StarAgent;

Expand Down Expand Up @@ -180,7 +182,16 @@ private void FixKillMode(SystemdSetting set)
exe = dll;
}

Host.Install(ServiceName, DisplayName, exe, "-s", Description);
var service = new ServiceModel
{
ServiceName = ServiceName,
DisplayName = DisplayName,
Description = Description,
FileName = exe,
Arguments = "-s",
};

Host.Install(service);
}
}
}
Expand Down

0 comments on commit c57f84e

Please sign in to comment.