星尘发布架构图;DeployAgent支持作为节点向服务端心跳

This commit is contained in:
智能大石头 2025-04-17 00:51:12 +08:00
parent 137b908c23
commit 69c80f42b5
5 changed files with 61 additions and 11 deletions

View File

@ -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>

View File

@ -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
}

View File

@ -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)
{

BIN
Doc/星尘发布.emmx Normal file

Binary file not shown.

BIN
Doc/星尘发布.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB