Skip to content

Commit

Permalink
[feat]发布中心要支持单个应用在指定服务器上部署多个版本。应用场景需求,希望应用App1能够在节点Node1上部署多个版本,如:App…
Browse files Browse the repository at this point in the history
…1A/App1B/App1C。

场景一
用户资源有限,希望在一台服务器上部署应用App1的测试版和生产版,端口不同。
可在发布节点里面添加两次节点Node1,命名发布集为:App1A/App1B,原来发布集统一使用应用名App1。
需要关闭自动发布,上传版本后,手工选择使用最新版本,然后在测试版App1B上点击发布。
待新版测试通过后,再电机App1A发布。

场景二
重要应用App1,仅有1台服务器,发布时需要重启,耗时1分钟左右,导致业务中断影响体验。
可在发布节点里面添加两次节点Node1,命名发布集为:App1A/App1B,原来发布集统一使用应用名App1。
配置两个发布的顺序和延迟时间(60秒),自动发布时,依次部署,间隔60秒。
前端nginx使用主备机制,确保发布过程中也有可用节点。
NewLifeX/Stardust#72
  • Loading branch information
猿人易 committed Sep 23, 2024
1 parent f173925 commit 3fa778c
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ jobs:
- name: Publish
run: |
dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://nuget.pkg.github.com/PeiKeSmart/index.json --api-key ${{ github.token }}
#dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://nuget.pkg.github.com/PeiKeSmart/index.json --api-key ${{ github.token }}
dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.nugetKey }}
dotnet nuget push ./out/*.nupkg --skip-duplicate --source https://nuget.chuangchu.net/v3/index.json --api-key ${{ secrets.mynugetKey }}
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ jobs:
- name: Publish
run: |
dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://nuget.pkg.github.com/PeiKeSmart/index.json --api-key ${{ github.token }}
#dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://nuget.pkg.github.com/PeiKeSmart/index.json --api-key ${{ github.token }}
dotnet nuget push .\out\*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.nugetKey }}
dotnet nuget push ./out/*.nupkg --skip-duplicate --source https://nuget.chuangchu.net/v3/index.json --api-key ${{ secrets.mynugetKey }}
7 changes: 4 additions & 3 deletions Stardust.Data/Deployment/Model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,20 @@
<Table Name="AppDeployNode" Description="应用节点。应用部署集和节点服务器的依赖关系,一个应用可有多个部署集如arm和x64,在目标节点上发布该部署集对应的应用zip包">
<Columns>
<Column Name="Id" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
<Column Name="DeployName" DataType="String" Description="发布名。默认为空,使用部署集上名字。可用于单节点多发布场景" />
<Column Name="DeployId" ColumnName="AppId" DataType="Int32" Map="AppDeploy@Id@$" Description="应用部署集。对应AppDeploy" />
<Column Name="NodeId" DataType="Int32" Description="节点。节点服务器" />
<Column Name="IP" DataType="String" Description="IP地址。节点所在内网IP地址" />
<Column Name="Sort" DataType="Int32" Description="顺序。较小在前,同时表示延迟发布秒数" />
<Column Name="Enable" DataType="Boolean" Description="启用" />
<Column Name="Environment" DataType="String" Description="环境。prod/test/dev/uat等" Category="发布参数" />
<Column Name="FileName" DataType="String" Description="文件。应用启动文件,可直接使用zip包,支持差异定制,为空时使用应用集配置" Category="发布参数" />
<Column Name="Arguments" DataType="String" Length="500" Description="参数。启动应用的参数,为空时使用应用集配置" Category="发布参数" />
<Column Name="WorkingDirectory" DataType="String" Length="200" Description="工作目录。应用根目录,为空时使用应用集配置" Category="发布参数" />
<Column Name="Environments" DataType="String" Length="500" Description="环境变量。启动应用前设置的环境变量" Category="发布参数" />
<Column Name="Mode" DataType="Int32" Description="工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip。为空时使用应用集配置" Type="Stardust.Models.ServiceModes" Category="发布参数" />
<Column Name="Delay" DataType="Int32" Description="延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒" Category="发布参数" />
<Column Name="ProcessId" DataType="Int32" Description="进程" Category="状态" />
<Column Name="ProcessName" DataType="String" Length="200" Description="进程名称" Category="状态" />
<Column Name="UserName" DataType="String" Description="用户名。启动该进程的用户名" Category="状态" />
<Column Name="ProcessName" DataType="String" Length="200" Description="进程名称" Category="状态" />
<Column Name="StartTime" DataType="DateTime" Description="进程时间" Category="状态" />
<Column Name="Version" DataType="String" Description="版本。客户端" Category="状态" />
<Column Name="Compile" DataType="DateTime" Description="编译时间。客户端" Category="状态" />
Expand Down
4 changes: 3 additions & 1 deletion Stardust.Data/Deployment/应用节点.Biz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ public ServiceInfo ToService(AppDeploy app)

var inf = new ServiceInfo
{
Name = app.Name,
Name = DeployName,
FileName = FileName,
Arguments = Arguments,
Environments = Environments,
WorkingDirectory = WorkingDirectory,

Enable = app.Enable && Enable,
Expand All @@ -187,6 +188,7 @@ public ServiceInfo ToService(AppDeploy app)
MaxMemory = app.MaxMemory,
Mode = Mode,
};
if (inf.Name.IsNullOrEmpty()) inf.Name = app.Name;
if (inf.FileName.IsNullOrEmpty()) inf.FileName = app.FileName;
if (inf.Arguments.IsNullOrEmpty()) inf.Arguments = app.Arguments;
if (inf.Environments.IsNullOrEmpty()) inf.Environments = app.Environments;
Expand Down
121 changes: 67 additions & 54 deletions Stardust.Data/Deployment/应用节点.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public partial class AppDeployNode
[BindColumn("Id", "编号", "")]
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }

private String _DeployName;
/// <summary>发布名。默认为空,使用部署集上名字。可用于单节点多发布场景</summary>
[DisplayName("发布名")]
[Description("发布名。默认为空,使用部署集上名字。可用于单节点多发布场景")]
[DataObjectField(false, false, true, 50)]
[BindColumn("DeployName", "发布名。默认为空,使用部署集上名字。可用于单节点多发布场景", "")]
public String DeployName { get => _DeployName; set { if (OnPropertyChanging("DeployName", value)) { _DeployName = value; OnPropertyChanged("DeployName"); } } }

private Int32 _DeployId;
/// <summary>应用部署集。对应AppDeploy</summary>
[DisplayName("应用部署集")]
Expand All @@ -55,14 +63,6 @@ public partial class AppDeployNode
[BindColumn("IP", "IP地址。节点所在内网IP地址", "")]
public String IP { get => _IP; set { if (OnPropertyChanging("IP", value)) { _IP = value; OnPropertyChanged("IP"); } } }

private Int32 _Sort;
/// <summary>顺序。较小在前,同时表示延迟发布秒数</summary>
[DisplayName("顺序")]
[Description("顺序。较小在前,同时表示延迟发布秒数")]
[DataObjectField(false, false, false, 0)]
[BindColumn("Sort", "顺序。较小在前,同时表示延迟发布秒数", "")]
public Int32 Sort { get => _Sort; set { if (OnPropertyChanging("Sort", value)) { _Sort = value; OnPropertyChanged("Sort"); } } }

private Boolean _Enable;
/// <summary>启用</summary>
[DisplayName("启用")]
Expand All @@ -71,15 +71,6 @@ public partial class AppDeployNode
[BindColumn("Enable", "启用", "")]
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }

private String _Environment;
/// <summary>环境。prod/test/dev/uat等</summary>
[Category("发布参数")]
[DisplayName("环境")]
[Description("环境。prod/test/dev/uat等")]
[DataObjectField(false, false, true, 50)]
[BindColumn("Environment", "环境。prod/test/dev/uat等", "")]
public String Environment { get => _Environment; set { if (OnPropertyChanging("Environment", value)) { _Environment = value; OnPropertyChanged("Environment"); } } }

private String _FileName;
/// <summary>文件。应用启动文件,可直接使用zip包,支持差异定制,为空时使用应用集配置</summary>
[Category("发布参数")]
Expand Down Expand Up @@ -107,6 +98,15 @@ public partial class AppDeployNode
[BindColumn("WorkingDirectory", "工作目录。应用根目录,为空时使用应用集配置", "")]
public String WorkingDirectory { get => _WorkingDirectory; set { if (OnPropertyChanging("WorkingDirectory", value)) { _WorkingDirectory = value; OnPropertyChanged("WorkingDirectory"); } } }

private String _Environments;
/// <summary>环境变量。启动应用前设置的环境变量</summary>
[Category("发布参数")]
[DisplayName("环境变量")]
[Description("环境变量。启动应用前设置的环境变量")]
[DataObjectField(false, false, true, 500)]
[BindColumn("Environments", "环境变量。启动应用前设置的环境变量", "")]
public String Environments { get => _Environments; set { if (OnPropertyChanging("Environments", value)) { _Environments = value; OnPropertyChanged("Environments"); } } }

private Stardust.Models.ServiceModes _Mode;
/// <summary>工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip。为空时使用应用集配置</summary>
[Category("发布参数")]
Expand All @@ -116,6 +116,15 @@ public partial class AppDeployNode
[BindColumn("Mode", "工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip。为空时使用应用集配置", "")]
public Stardust.Models.ServiceModes Mode { get => _Mode; set { if (OnPropertyChanging("Mode", value)) { _Mode = value; OnPropertyChanged("Mode"); } } }

private Int32 _Delay;
/// <summary>延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒</summary>
[Category("发布参数")]
[DisplayName("延迟")]
[Description("延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒")]
[DataObjectField(false, false, false, 0)]
[BindColumn("Delay", "延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒", "")]
public Int32 Delay { get => _Delay; set { if (OnPropertyChanging("Delay", value)) { _Delay = value; OnPropertyChanged("Delay"); } } }

private Int32 _ProcessId;
/// <summary>进程</summary>
[Category("状态")]
Expand All @@ -125,15 +134,6 @@ public partial class AppDeployNode
[BindColumn("ProcessId", "进程", "")]
public Int32 ProcessId { get => _ProcessId; set { if (OnPropertyChanging("ProcessId", value)) { _ProcessId = value; OnPropertyChanged("ProcessId"); } } }

private String _ProcessName;
/// <summary>进程名称</summary>
[Category("状态")]
[DisplayName("进程名称")]
[Description("进程名称")]
[DataObjectField(false, false, true, 200)]
[BindColumn("ProcessName", "进程名称", "")]
public String ProcessName { get => _ProcessName; set { if (OnPropertyChanging("ProcessName", value)) { _ProcessName = value; OnPropertyChanged("ProcessName"); } } }

private String _UserName;
/// <summary>用户名。启动该进程的用户名</summary>
[Category("状态")]
Expand All @@ -143,6 +143,15 @@ public partial class AppDeployNode
[BindColumn("UserName", "用户名。启动该进程的用户名", "")]
public String UserName { get => _UserName; set { if (OnPropertyChanging("UserName", value)) { _UserName = value; OnPropertyChanged("UserName"); } } }

private String _ProcessName;
/// <summary>进程名称</summary>
[Category("状态")]
[DisplayName("进程名称")]
[Description("进程名称")]
[DataObjectField(false, false, true, 200)]
[BindColumn("ProcessName", "进程名称", "")]
public String ProcessName { get => _ProcessName; set { if (OnPropertyChanging("ProcessName", value)) { _ProcessName = value; OnPropertyChanged("ProcessName"); } } }

private DateTime _StartTime;
/// <summary>进程时间</summary>
[Category("状态")]
Expand Down Expand Up @@ -279,19 +288,20 @@ public override Object this[String name]
get => name switch
{
"Id" => _Id,
"DeployName" => _DeployName,
"DeployId" => _DeployId,
"NodeId" => _NodeId,
"IP" => _IP,
"Sort" => _Sort,
"Enable" => _Enable,
"Environment" => _Environment,
"FileName" => _FileName,
"Arguments" => _Arguments,
"WorkingDirectory" => _WorkingDirectory,
"Environments" => _Environments,
"Mode" => _Mode,
"Delay" => _Delay,
"ProcessId" => _ProcessId,
"ProcessName" => _ProcessName,
"UserName" => _UserName,
"ProcessName" => _ProcessName,
"StartTime" => _StartTime,
"Version" => _Version,
"Compile" => _Compile,
Expand All @@ -313,19 +323,20 @@ public override Object this[String name]
switch (name)
{
case "Id": _Id = value.ToInt(); break;
case "DeployName": _DeployName = Convert.ToString(value); break;
case "DeployId": _DeployId = value.ToInt(); break;
case "NodeId": _NodeId = value.ToInt(); break;
case "IP": _IP = Convert.ToString(value); break;
case "Sort": _Sort = value.ToInt(); break;
case "Enable": _Enable = value.ToBoolean(); break;
case "Environment": _Environment = Convert.ToString(value); break;
case "FileName": _FileName = Convert.ToString(value); break;
case "Arguments": _Arguments = Convert.ToString(value); break;
case "WorkingDirectory": _WorkingDirectory = Convert.ToString(value); break;
case "Environments": _Environments = Convert.ToString(value); break;
case "Mode": _Mode = (Stardust.Models.ServiceModes)value.ToInt(); break;
case "Delay": _Delay = value.ToInt(); break;
case "ProcessId": _ProcessId = value.ToInt(); break;
case "ProcessName": _ProcessName = Convert.ToString(value); break;
case "UserName": _UserName = Convert.ToString(value); break;
case "ProcessName": _ProcessName = Convert.ToString(value); break;
case "StartTime": _StartTime = value.ToDateTime(); break;
case "Version": _Version = Convert.ToString(value); break;
case "Compile": _Compile = value.ToDateTime(); break;
Expand All @@ -351,10 +362,6 @@ public override Object this[String name]
[XmlIgnore, IgnoreDataMember, ScriptIgnore]
public AppDeploy Deploy => Extends.Get(nameof(Deploy), k => AppDeploy.FindById(DeployId));

/// <summary>应用部署集</summary>
[Map(nameof(DeployId), typeof(AppDeploy), "Id")]
public String DeployName => Deploy?.ToString();

#endregion

#region 扩展查询
Expand All @@ -367,6 +374,9 @@ public partial class _
/// <summary>编号</summary>
public static readonly Field Id = FindByName("Id");

/// <summary>发布名。默认为空,使用部署集上名字。可用于单节点多发布场景</summary>
public static readonly Field DeployName = FindByName("DeployName");

/// <summary>应用部署集。对应AppDeploy</summary>
public static readonly Field DeployId = FindByName("DeployId");

Expand All @@ -376,15 +386,9 @@ public partial class _
/// <summary>IP地址。节点所在内网IP地址</summary>
public static readonly Field IP = FindByName("IP");

/// <summary>顺序。较小在前,同时表示延迟发布秒数</summary>
public static readonly Field Sort = FindByName("Sort");

/// <summary>启用</summary>
public static readonly Field Enable = FindByName("Enable");

/// <summary>环境。prod/test/dev/uat等</summary>
public static readonly Field Environment = FindByName("Environment");

/// <summary>文件。应用启动文件,可直接使用zip包,支持差异定制,为空时使用应用集配置</summary>
public static readonly Field FileName = FindByName("FileName");

Expand All @@ -394,18 +398,24 @@ public partial class _
/// <summary>工作目录。应用根目录,为空时使用应用集配置</summary>
public static readonly Field WorkingDirectory = FindByName("WorkingDirectory");

/// <summary>环境变量。启动应用前设置的环境变量</summary>
public static readonly Field Environments = FindByName("Environments");

/// <summary>工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip。为空时使用应用集配置</summary>
public static readonly Field Mode = FindByName("Mode");

/// <summary>延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒</summary>
public static readonly Field Delay = FindByName("Delay");

/// <summary>进程</summary>
public static readonly Field ProcessId = FindByName("ProcessId");

/// <summary>进程名称</summary>
public static readonly Field ProcessName = FindByName("ProcessName");

/// <summary>用户名。启动该进程的用户名</summary>
public static readonly Field UserName = FindByName("UserName");

/// <summary>进程名称</summary>
public static readonly Field ProcessName = FindByName("ProcessName");

/// <summary>进程时间</summary>
public static readonly Field StartTime = FindByName("StartTime");

Expand Down Expand Up @@ -457,6 +467,9 @@ public partial class __
/// <summary>编号</summary>
public const String Id = "Id";

/// <summary>发布名。默认为空,使用部署集上名字。可用于单节点多发布场景</summary>
public const String DeployName = "DeployName";

/// <summary>应用部署集。对应AppDeploy</summary>
public const String DeployId = "DeployId";

Expand All @@ -466,15 +479,9 @@ public partial class __
/// <summary>IP地址。节点所在内网IP地址</summary>
public const String IP = "IP";

/// <summary>顺序。较小在前,同时表示延迟发布秒数</summary>
public const String Sort = "Sort";

/// <summary>启用</summary>
public const String Enable = "Enable";

/// <summary>环境。prod/test/dev/uat等</summary>
public const String Environment = "Environment";

/// <summary>文件。应用启动文件,可直接使用zip包,支持差异定制,为空时使用应用集配置</summary>
public const String FileName = "FileName";

Expand All @@ -484,18 +491,24 @@ public partial class __
/// <summary>工作目录。应用根目录,为空时使用应用集配置</summary>
public const String WorkingDirectory = "WorkingDirectory";

/// <summary>环境变量。启动应用前设置的环境变量</summary>
public const String Environments = "Environments";

/// <summary>工作模式。0默认exe/zip;1仅解压;2解压后运行;3仅运行一次;4多实例exe/zip。为空时使用应用集配置</summary>
public const String Mode = "Mode";

/// <summary>延迟。批量发布时,需要延迟执行的时间,用于滚动发布,单位秒</summary>
public const String Delay = "Delay";

/// <summary>进程</summary>
public const String ProcessId = "ProcessId";

/// <summary>进程名称</summary>
public const String ProcessName = "ProcessName";

/// <summary>用户名。启动该进程的用户名</summary>
public const String UserName = "UserName";

/// <summary>进程名称</summary>
public const String ProcessName = "ProcessName";

/// <summary>进程时间</summary>
public const String StartTime = "StartTime";

Expand Down
2 changes: 1 addition & 1 deletion Stardust.Web.Vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"sass": "^1.26.2",
"sass-loader": "^8.0.2",
"typescript": "^4.5.2",
"vite": "^4.5.2",
"vite": "^4.5.5",
"vue-tsc": "^1.0.24"
}
}
Loading

0 comments on commit 3fa778c

Please sign in to comment.