DH.Extensions.Hosting.AgentService
3.91.2024.1013-beta0845
See the version list below for details.
dotnet add package DH.Extensions.Hosting.AgentService --version 3.91.2024.1013-beta0845
NuGet\Install-Package DH.Extensions.Hosting.AgentService -Version 3.91.2024.1013-beta0845
<PackageReference Include="DH.Extensions.Hosting.AgentService" Version="3.91.2024.1013-beta0845" />
paket add DH.Extensions.Hosting.AgentService --version 3.91.2024.1013-beta0845
#r "nuget: DH.Extensions.Hosting.AgentService, 3.91.2024.1013-beta0845"
// Install DH.Extensions.Hosting.AgentService as a Cake Addin #addin nuget:?package=DH.Extensions.Hosting.AgentService&version=3.91.2024.1013-beta0845&prerelease // Install DH.Extensions.Hosting.AgentService as a Cake Tool #tool nuget:?package=DH.Extensions.Hosting.AgentService&version=3.91.2024.1013-beta0845&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 is compatible. 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 | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- DH.NAgent (>= 3.91.2024.1013-beta0845)
- Microsoft.Extensions.Hosting.Abstractions (>= 3.1.0)
- Microsoft.Extensions.Options (>= 3.1.0)
-
net5.0
- DH.NAgent (>= 3.91.2024.1013-beta0845)
- Microsoft.Extensions.Hosting.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Options (>= 5.0.0)
-
net6.0
- DH.NAgent (>= 3.91.2024.1013-beta0845)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
-
net7.0
- DH.NAgent (>= 3.91.2024.1013-beta0845)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.0)
-
net8.0
- DH.NAgent (>= 3.91.2024.1013-beta0845)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
支持Web、WebApi和Worker等现代化项目