版本升级过渡,逐步替代AutoStart
This commit is contained in:
parent
25c0d6f68d
commit
ca641174b9
|
@ -56,7 +56,7 @@ namespace StarAgent
|
|||
FileName = "ping",
|
||||
Arguments = "newlifex.com",
|
||||
|
||||
AutoStart = false,
|
||||
Enable = false,
|
||||
//ReloadOnChange = true,
|
||||
};
|
||||
var si2 = new ServiceInfo
|
||||
|
@ -65,12 +65,18 @@ namespace StarAgent
|
|||
FileName = "ping",
|
||||
Arguments = "feifan.link",
|
||||
|
||||
AutoStart = false,
|
||||
Enable = false,
|
||||
};
|
||||
|
||||
Services = new[] { si, si2 };
|
||||
}
|
||||
|
||||
// 版本升级过渡,逐步替代AutoStart
|
||||
foreach (var svc in Services)
|
||||
{
|
||||
svc.Enable = svc.AutoStart;
|
||||
}
|
||||
|
||||
base.OnLoaded();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<Column Name="FileName" DataType="String" Description="文件。应用启动文件,Zip应用包使用ZipDeploy" Category="参数" />
|
||||
<Column Name="Arguments" DataType="String" Description="参数。启动应用的参数" Category="参数" />
|
||||
<Column Name="WorkingDirectory" DataType="String" Description="工作目录。应用根目录" Category="参数" />
|
||||
<Column Name="AutoStart" DataType="Boolean" Description="自动启动。系统重启时,或应用退出后,自动拉起应用" Category="参数" />
|
||||
<Column Name="MaxMemory" DataType="Int32" Description="最大内存。单位M,超过上限时自动重启应用,默认0不限制" Category="参数" />
|
||||
<Column Name="CreateUserId" DataType="Int32" Description="创建者" Category="扩展" />
|
||||
<Column Name="CreateTime" DataType="DateTime" Description="创建时间" Category="扩展" />
|
||||
|
|
|
@ -159,17 +159,6 @@
|
|||
<td>应用根目录</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>AutoStart</td>
|
||||
<td>自动启动</td>
|
||||
<td>Boolean</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>N</td>
|
||||
<td>系统重启时,或应用退出后,自动拉起应用</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>MaxMemory</td>
|
||||
<td>最大内存</td>
|
||||
|
|
|
@ -136,7 +136,8 @@ public partial class AppDeployNode : Entity<AppDeployNode>
|
|||
Arguments = !Arguments.IsNullOrEmpty() ? Arguments : app.Arguments,
|
||||
WorkingDirectory = !WorkingDirectory.IsNullOrEmpty() ? WorkingDirectory : app.WorkingDirectory,
|
||||
|
||||
AutoStart = app.AutoStart,
|
||||
Enable = app.Enable,
|
||||
//AutoStart = app.AutoStart,
|
||||
//AutoStop = app.AutoStop,
|
||||
MaxMemory = app.MaxMemory,
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Stardust.Data.Deployment
|
|||
}
|
||||
|
||||
//if (!isNew) Nodes = AppDeployNode.FindAllByAppId(Id).Count;
|
||||
if (isNew && !Dirtys[nameof(AutoStart)]) AutoStart = true;
|
||||
//if (isNew && !Dirtys[nameof(AutoStart)]) AutoStart = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -102,15 +102,6 @@ namespace Stardust.Data.Deployment
|
|||
[BindColumn("WorkingDirectory", "工作目录。应用根目录", "")]
|
||||
public String WorkingDirectory { get => _WorkingDirectory; set { if (OnPropertyChanging("WorkingDirectory", value)) { _WorkingDirectory = value; OnPropertyChanged("WorkingDirectory"); } } }
|
||||
|
||||
private Boolean _AutoStart;
|
||||
/// <summary>自动启动。系统重启时,或应用退出后,自动拉起应用</summary>
|
||||
[Category("参数")]
|
||||
[DisplayName("自动启动")]
|
||||
[Description("自动启动。系统重启时,或应用退出后,自动拉起应用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("AutoStart", "自动启动。系统重启时,或应用退出后,自动拉起应用", "")]
|
||||
public Boolean AutoStart { get => _AutoStart; set { if (OnPropertyChanging("AutoStart", value)) { _AutoStart = value; OnPropertyChanged("AutoStart"); } } }
|
||||
|
||||
private Int32 _MaxMemory;
|
||||
/// <summary>最大内存。单位M,超过上限时自动重启应用,默认0不限制</summary>
|
||||
[Category("参数")]
|
||||
|
@ -204,7 +195,6 @@ namespace Stardust.Data.Deployment
|
|||
case "FileName": return _FileName;
|
||||
case "Arguments": return _Arguments;
|
||||
case "WorkingDirectory": return _WorkingDirectory;
|
||||
case "AutoStart": return _AutoStart;
|
||||
case "MaxMemory": return _MaxMemory;
|
||||
case "CreateUserId": return _CreateUserId;
|
||||
case "CreateTime": return _CreateTime;
|
||||
|
@ -230,7 +220,6 @@ namespace Stardust.Data.Deployment
|
|||
case "FileName": _FileName = Convert.ToString(value); break;
|
||||
case "Arguments": _Arguments = Convert.ToString(value); break;
|
||||
case "WorkingDirectory": _WorkingDirectory = Convert.ToString(value); break;
|
||||
case "AutoStart": _AutoStart = value.ToBoolean(); break;
|
||||
case "MaxMemory": _MaxMemory = value.ToInt(); break;
|
||||
case "CreateUserId": _CreateUserId = value.ToInt(); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
|
@ -279,9 +268,6 @@ namespace Stardust.Data.Deployment
|
|||
/// <summary>工作目录。应用根目录</summary>
|
||||
public static readonly Field WorkingDirectory = FindByName("WorkingDirectory");
|
||||
|
||||
/// <summary>自动启动。系统重启时,或应用退出后,自动拉起应用</summary>
|
||||
public static readonly Field AutoStart = FindByName("AutoStart");
|
||||
|
||||
/// <summary>最大内存。单位M,超过上限时自动重启应用,默认0不限制</summary>
|
||||
public static readonly Field MaxMemory = FindByName("MaxMemory");
|
||||
|
||||
|
@ -342,9 +328,6 @@ namespace Stardust.Data.Deployment
|
|||
/// <summary>工作目录。应用根目录</summary>
|
||||
public const String WorkingDirectory = "WorkingDirectory";
|
||||
|
||||
/// <summary>自动启动。系统重启时,或应用退出后,自动拉起应用</summary>
|
||||
public const String AutoStart = "AutoStart";
|
||||
|
||||
/// <summary>最大内存。单位M,超过上限时自动重启应用,默认0不限制</summary>
|
||||
public const String MaxMemory = "MaxMemory";
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ public class DeployController : BaseController
|
|||
if (app.Arguments.IsNullOrEmpty()) app.Arguments = svc.Arguments;
|
||||
if (app.WorkingDirectory.IsNullOrEmpty()) app.WorkingDirectory = svc.WorkingDirectory;
|
||||
|
||||
app.AutoStart = svc.AutoStart;
|
||||
app.Enable = svc.Enable;
|
||||
//app.AutoStart = svc.AutoStart;
|
||||
//app.AutoStop = svc.AutoStop;
|
||||
app.MaxMemory = svc.MaxMemory;
|
||||
|
||||
|
|
|
@ -378,19 +378,7 @@ public class NodeService
|
|||
var deploy = item.App;
|
||||
if (deploy == null || !deploy.Enable) continue;
|
||||
|
||||
var svc = new ServiceInfo
|
||||
{
|
||||
Name = deploy.Name,
|
||||
FileName = deploy.FileName,
|
||||
Arguments = deploy.Arguments,
|
||||
WorkingDirectory = deploy.WorkingDirectory,
|
||||
AutoStart = deploy.AutoStart,
|
||||
//Singleton = true,
|
||||
};
|
||||
if (!item.Arguments.IsNullOrEmpty()) svc.Arguments = item.Arguments;
|
||||
if (!item.WorkingDirectory.IsNullOrEmpty()) svc.WorkingDirectory = item.WorkingDirectory;
|
||||
|
||||
svcs.Add(svc);
|
||||
svcs.Add(item.ToService());
|
||||
}
|
||||
|
||||
return svcs.ToArray();
|
||||
|
|
|
@ -88,7 +88,7 @@ public class AppDeployController : EntityController<AppDeploy>
|
|||
if (type == DataObjectMethodType.Insert)
|
||||
{
|
||||
entity.Enable = true;
|
||||
entity.AutoStart = true;
|
||||
//entity.AutoStart = true;
|
||||
}
|
||||
|
||||
return base.Valid(entity, type, post);
|
||||
|
|
|
@ -369,7 +369,7 @@ public class LocalStarClient
|
|||
FileName = fileName,
|
||||
Arguments = arguments,
|
||||
WorkingDirectory = workingDirectory,
|
||||
AutoStart = true,
|
||||
Enable = true,
|
||||
//ReloadOnChange = true,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
using System.Xml.Linq;
|
||||
using NewLife;
|
||||
using NewLife;
|
||||
using NewLife.IO;
|
||||
using NewLife.Log;
|
||||
using NewLife.Serialization;
|
||||
using NewLife.Threading;
|
||||
using Stardust.Models;
|
||||
using Stardust.Services;
|
||||
using static NewLife.Remoting.ApiHttpClient;
|
||||
|
||||
namespace Stardust.Managers;
|
||||
|
||||
|
@ -253,6 +251,7 @@ public class ServiceManager : DisposeBase
|
|||
svc.FileName = item.Name;
|
||||
svc.Arguments = item.Arguments;
|
||||
svc.WorkingDirectory = item.WorkingDirectory;
|
||||
svc.Enable = item.Enable;
|
||||
svc.AutoStart = item.AutoStart;
|
||||
//svc.AutoStop = item.AutoStop;
|
||||
svc.MaxMemory = item.MaxMemory;
|
||||
|
@ -294,7 +293,7 @@ public class ServiceManager : DisposeBase
|
|||
var changed = false;
|
||||
foreach (var item in svcs)
|
||||
{
|
||||
if (item != null && item.AutoStart)
|
||||
if (item != null && item.Enable)
|
||||
{
|
||||
changed |= StartService(item);
|
||||
}
|
||||
|
@ -306,7 +305,7 @@ public class ServiceManager : DisposeBase
|
|||
{
|
||||
var controller = controllers[i];
|
||||
var service = svcs.FirstOrDefault(e => e.Name.EqualIgnoreCase(controller.Name));
|
||||
if (service == null || !service.AutoStart)
|
||||
if (service == null || !service.Enable)
|
||||
{
|
||||
controller.Stop("配置停止");
|
||||
controllers.RemoveAt(i);
|
||||
|
|
|
@ -23,6 +23,10 @@ public class ServiceInfo
|
|||
[XmlAttribute]
|
||||
public String WorkingDirectory { get; set; }
|
||||
|
||||
/// <summary>启用</summary>
|
||||
[XmlAttribute]
|
||||
public Boolean Enable { get; set; }
|
||||
|
||||
/// <summary>是否自动启动</summary>
|
||||
[XmlAttribute]
|
||||
public Boolean AutoStart { get; set; }
|
||||
|
|
Loading…
Reference in New Issue