Skip to content

Commit

Permalink
提起共用的服务对象模型ServiceModel
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 2, 2024
1 parent 75efe00 commit ad0f4c7
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 32 deletions.
1 change: 1 addition & 0 deletions NewLife.Agent/Command/CommandHandlerFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using NewLife.Agent.Models;

namespace NewLife.Agent.Command;

Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/DefaultHost.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Diagnostics;
using NewLife.Agent.Models;
using NewLife.Log;

namespace NewLife.Agent;
Expand Down
4 changes: 3 additions & 1 deletion NewLife.Agent/IHost.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NewLife.Agent;
using NewLife.Agent.Models;

namespace NewLife.Agent;

/// <summary>服务主机</summary>
public interface IHost
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Agent/Menu.cs → NewLife.Agent/Models/Menu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NewLife.Agent;
namespace NewLife.Agent.Models;

/// <summary>
/// 菜单信息
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NewLife.Agent;
namespace NewLife.Agent.Models;

/// <summary>服务配置</summary>
public class ServiceConfig
Expand Down
31 changes: 31 additions & 0 deletions NewLife.Agent/Models/ServiceModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace NewLife.Agent.Models;

/// <summary>服务模型</summary>
public class ServiceModel
{
#region 属性
/// <summary>服务名</summary>
public String ServiceName { get; set; }

/// <summary>中文名</summary>
public String DisplayName { get; set; }

/// <summary>描述</summary>
public String Description { get; set; }

/// <summary>文件名</summary>
public String FileName { get; set; }

/// <summary>参数</summary>
public String Arguments { get; set; }

/// <summary>工作目录</summary>
public String WorkingDirectory { get; set; }

/// <summary>用户</summary>
public String User { get; set; }

/// <summary>组</summary>
public String Group { get; set; }
#endregion
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
using System.Text;

namespace NewLife.Agent;
namespace NewLife.Agent.Models;

/// <summary>Systemd服务设置</summary>
public class SystemdSetting
public class SystemdSetting : ServiceModel
{
#region 属性
/// <summary>服务名</summary>
public String ServiceName { get; set; }

/// <summary>中文名</summary>
public String DisplayName { get; set; }

/// <summary>描述</summary>
public String Description { get; set; }

/// <summary>文件名</summary>
public String FileName { get; set; }

/// <summary>参数</summary>
public String Arguments { get; set; }

/// <summary>工作目录</summary>
public String WorkingDirectory { get; set; }

/// <summary>类型。simple/forking/oneshot/dbus/notify/idle</summary>
public String Type { get; set; } = "simple";

/// <summary>环境变量。可以指定服务会用到的环境变量</summary>
public String Environment { get; set; }

/// <summary>用户</summary>
public String User { get; set; }

/// <summary>组</summary>
public String Group { get; set; }

/// <summary>重启策略。no/on-success/on-failure/on-abnormal/on-watchdog/on-abort/always</summary>
public String Restart { get; set; } = "always";

Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/OSXLaunch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using NewLife.Agent.Models;
using NewLife.Log;

namespace NewLife.Agent;
Expand Down
7 changes: 4 additions & 3 deletions NewLife.Agent/ServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using System.Security;
using NewLife.Agent.Command;
using NewLife.Agent.Models;
using NewLife.Agent.Windows;
using NewLife.Log;
using NewLife.Reflection;
Expand Down Expand Up @@ -109,7 +110,7 @@ public void Main(String[] args)

Command.Handle(CommandConst.ShowStatus, args);
// 输出状态,菜单循环
ProcessMenu();
ProcessMenu(args);
}

// 释放文本文件日志对象,确保日志队列内容写入磁盘
Expand Down Expand Up @@ -178,11 +179,11 @@ protected virtual void Init()
}

/// <summary>显示状态</summary>
protected virtual void ProcessMenu()
protected virtual void ProcessMenu(String[] args)
{
var service = this;
var name = ServiceName;
var args = Environment.GetCommandLineArgs();
//var args = Environment.GetCommandLineArgs();
while (true)
{
//输出菜单
Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/SysVinit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using NewLife.Agent.Models;
using NewLife.Log;

namespace NewLife.Agent;
Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/Systemd.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using NewLife.Agent.Models;
using NewLife.Log;
using NewLife.Serialization;

Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/WindowsAutorun.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Runtime.Versioning;
using Microsoft.Win32;
using NewLife.Agent.Models;
using NewLife.Agent.Windows;
using NewLife.Log;

Expand Down
1 change: 1 addition & 0 deletions NewLife.Agent/WindowsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using NewLife.Agent.Models;
using NewLife.Agent.Windows;
using NewLife.Log;
using NewLife.Threading;
Expand Down

0 comments on commit ad0f4c7

Please sign in to comment.