星尘发布架构图;DeployAgent支持作为节点向服务端心跳
This commit is contained in:
parent
137b908c23
commit
69c80f42b5
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net461;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||
<AssemblyTitle>星尘发布</AssemblyTitle>
|
||||
<Description>自动下载代码,编译后打包输出并推送发布中心。</Description>
|
||||
<Company>新生命开发团队</Company>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System.ComponentModel;
|
||||
using NewLife.Configuration;
|
||||
using NewLife.Remoting.Clients;
|
||||
|
||||
namespace DeployAgent;
|
||||
|
||||
/// <summary>配置</summary>
|
||||
[Config("DeployAgent")]
|
||||
public class DeploySetting : Config<DeploySetting>, IClientSetting
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>服务端地址</summary>
|
||||
[Description("服务端地址")]
|
||||
public String Server { get; set; } = "http://localhost:6600";
|
||||
|
||||
/// <summary>客户端编码</summary>
|
||||
[Description("客户端编码")]
|
||||
public String Code { get; set; }
|
||||
|
||||
/// <summary>客户端密钥</summary>
|
||||
[Description("客户端密钥")]
|
||||
public String Secret { get; set; }
|
||||
#endregion
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using NewLife;
|
||||
using NewLife;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Remoting.Clients;
|
||||
using NewLife.Serialization;
|
||||
|
@ -7,23 +8,48 @@ using Stardust.Models;
|
|||
|
||||
namespace DeployAgent;
|
||||
|
||||
public class DeployWorker : IHostedService
|
||||
public class DeployWorker(StarFactory factory) : IHostedService
|
||||
{
|
||||
private readonly StarFactory _factory;
|
||||
|
||||
public DeployWorker(StarFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
private StarClient _client;
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_factory.App.RegisterCommand("deploy/compile", OnCompile);
|
||||
XTrace.WriteLine("开始Deploy客户端");
|
||||
|
||||
var set = DeploySetting.Current;
|
||||
|
||||
// 产品编码、产品密钥从IoT管理平台获取,设备编码支持自动注册
|
||||
var client = new StarClient(factory.Server)
|
||||
{
|
||||
Code = set.Code,
|
||||
Secret = set.Secret,
|
||||
ProductCode = factory.AppId,
|
||||
Setting = set,
|
||||
|
||||
Tracer = factory.Tracer,
|
||||
Log = XTrace.Log,
|
||||
};
|
||||
|
||||
// 禁用客户端特性
|
||||
client.Features &= ~Features.Upgrade;
|
||||
|
||||
client.Open();
|
||||
|
||||
Host.RegisterExit(() => client.Logout("ApplicationExit"));
|
||||
|
||||
_client = client;
|
||||
|
||||
client.RegisterCommand("deploy/compile", OnCompile);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_client.TryDispose();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private String OnCompile(String args)
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
Loading…
Reference in New Issue