DH.NAgent
3.7.2024.911-beta0831
See the version list below for details.
dotnet add package DH.NAgent --version 3.7.2024.911-beta0831
NuGet\Install-Package DH.NAgent -Version 3.7.2024.911-beta0831
<PackageReference Include="DH.NAgent" Version="3.7.2024.911-beta0831" />
paket add DH.NAgent --version 3.7.2024.911-beta0831
#r "nuget: DH.NAgent, 3.7.2024.911-beta0831"
// Install DH.NAgent as a Cake Addin #addin nuget:?package=DH.NAgent&version=3.7.2024.911-beta0831&prerelease // Install DH.NAgent as a Cake Tool #tool nuget:?package=DH.NAgent&version=3.7.2024.911-beta0831&prerelease
DH.NAgent - 守护服务管理组件
功能特点
DH.NAgent是一个服务管理框架,用于开发随系统自动启动的长时间运行后台应用程序,支持Windows/Linux。
在Windows上注册为Windows服务,在Linux上注册为Systemd守护进程。
Agent支持netstandard2.0/net45/net40/mono
,旧版本还支持net20(已不再维护)。
Agent常用于各种后台应用,如aspnetcore应用、RPC网络服务器、MQTT服务器、数据处理应用、数据消费应用(Redis/RocketMQ)等。同类软件有 NSSM、srvany,但并不一样,Agent是框架,而它们是具体软件,更像星尘代理 StarAgent。
DH.NAgent主要功能:
- 注册应用为系统服务或守护进程,随系统自动启动
- 支持控制台菜单控制安装、卸载、启动、停止,以及查看状态
- 支持控制台调试应用,解决Windows服务难以调试的问题
- 支持健康检测,限制内存、线程数、句柄数,超限时重启应用服务
- 支持应用服务定时重启,通过配置指定
- 支持看门狗WatchDog,通过配置指定要守护的目标应用服务,如果目标停止则启动
- 支持配置文件修改服务名,一个应用程序可在多个目录上部署为不同的系统服务
服务控制
一个服务代理示例跑起来的样子
这是Agent的标准控制台(Windows和Centos)。上面是该服务的状态信息,下面是控制菜单。
示例分析:
- 服务名 XAgent/StarAgent,可以命令启动停止,Windows是
net start XAgent/net stop XAgent
,Linux是systemctl start StarAgent/systemctl stop StarAgent
。 - 显示名“新生命服务代理”是在windows服务控制板里面看到的名字
- 下一段信息给出了DH.NAgent和当前应用的版本信息和编译时间
- 黄色菜单可通过按键选择相应操作,内置012345,可自定义其它按键操作
- 菜单1,显示状态,按下1后刷新状态信息
- 菜单2,安装服务或卸载服务,安装成功后,显示信息变为卸载服务,反之亦然
- 菜单3,启动服务或停止服务,安装后才可以看见
- 菜单4,重启服务,安装且运行后可以看见
- 菜单5,模拟运行,在当前进程启动应用主逻辑,用于业务逻辑调试,等同于Windows服务调用
- 菜单0,退出应用服务
!!!注意,服务安装、卸载、启动、停止,在Windows/Linux上需要管理员权限运行
服务应用在Windows上以本地用户权限运行,有最高权限;
服务应用在Linux上以root权限运行,有最高权限;
该设计尽管带来了一定安全风险,但能够避免绝大部分初级用户的简单问题,优先易用性。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- DH.NCore (>= 3.7.2024.911-beta0807)
-
.NETFramework 4.6.1
- DH.NCore (>= 3.7.2024.911-beta0807)
-
.NETStandard 2.0
- DH.NCore (>= 3.7.2024.911-beta0807)
-
.NETStandard 2.1
- DH.NCore (>= 3.7.2024.911-beta0807)
-
net6.0
- DH.NCore (>= 3.7.2024.911-beta0807)
-
net7.0
- DH.NCore (>= 3.7.2024.911-beta0807)
-
net8.0
- DH.NCore (>= 3.7.2024.911-beta0807)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DH.NAgent:
Package | Downloads |
---|---|
DH.Extensions.Hosting.AgentService
应用程序注册为系统服务,支持Windows/Linux |
GitHub repositories
This package is not used by any popular GitHub repositories.
新增Desktop,支持Windows后台服务在用户会话打开应用;重构菜单架构;增强Systemd支持更多参数设置