NewLife.Agent
10.15.2026.402
dotnet add package NewLife.Agent --version 10.15.2026.402
NuGet\Install-Package NewLife.Agent -Version 10.15.2026.402
<PackageReference Include="NewLife.Agent" Version="10.15.2026.402" />
<PackageVersion Include="NewLife.Agent" Version="10.15.2026.402" />
<PackageReference Include="NewLife.Agent" />
paket add NewLife.Agent --version 10.15.2026.402
#r "nuget: NewLife.Agent, 10.15.2026.402"
#:package NewLife.Agent@10.15.2026.402
#addin nuget:?package=NewLife.Agent&version=10.15.2026.402
#tool nuget:?package=NewLife.Agent&version=10.15.2026.402
NewLife.Agent - 跨平台服务守护与运维框架
使用教程:https://newlifex.com/core/agent
产品介绍
NewLife.Agent 是一个面向长期运行应用的服务化框架,支持将控制台/Web/Worker 程序快速托管为系统服务,并统一提供安装、启停、监控、重启与排障能力。
支持平台:
- Windows(服务 / 登录自启动)
- Linux(Systemd / Procd / RcInit 等)
- macOS(LaunchAgent)
支持框架:
NewLife.Agent:net40;net45;net461;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0;net9.0;net10.0NewLife.Extensions.Hosting.AgentService:netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0
亮点
- 开发与运维一体化:继承
ServiceBase即可获得服务治理能力。 - 跨平台自动适配:按系统自动选择最合适宿主实现。
- 内置命令体系:支持
-install/-start/-stop/-restart/-status/-run。 - 健康监控与自愈:内存/线程/句柄阈值、定时重启、WatchDog。
- 多实例友好:通过配置不同
ServiceName可一程序多实例部署。 - Host 集成扩展包:可将 ASP.NET Core/Worker 纳入统一服务生命周期管理。
主要使用方式
1)最小服务程序
继承 ServiceBase,在入口调用 Main(args):
- 重写
StartWork(String reason)启动业务 - 重写
StopWork(String reason)停止业务并清理资源
2)命令行运维
常用命令:
-install:安装服务-start:启动服务-stop:停止服务-restart:重启服务-status:查看状态-uninstall:卸载服务-run:控制台模拟运行(调试)
安装/卸载/启停通常需要管理员(Windows)或 root(Linux)权限。
3)ASP.NET Core / Worker 集成
引用 NewLife.Extensions.Hosting.AgentService,在 HostBuilder 调用 UseAgentService(),即可将通用主机生命周期与 Agent 服务治理能力打通。
详细文档
快速拥有
dotnet new install NewLife.Templates
dotnet new service --name agent
cd agent
dotnet run
新生命项目矩阵
各项目默认支持net9.0/netstandard2.1/netstandard2.0/net4.62/net4.5,旧版(2024.0801)支持net4.0/net2.0
| 项目 | 年份 | 说明 |
|---|---|---|
| 基础组件 | 支撑其它中间件以及产品项目 | |
| NewLife.Core | 2002 | 核心库,日志、配置、缓存、网络、序列化、APM性能追踪 |
| NewLife.XCode | 2005 | 大数据中间件,单表百亿级,MySql/SQLite/SqlServer/Oracle/PostgreSql/达梦,自动分表,读写分离 |
| NewLife.Net | 2005 | 网络库,单机千万级吞吐率(2266万tps),单机百万级连接(400万Tcp长连接) |
| NewLife.Remoting | 2011 | 协议通信库,提供CS应用通信框架,支持Http/RPC通信框架,高吞吐,物联网设备低开销易接入 |
| NewLife.Cube | 2010 | 魔方快速开发平台,集成了用户权限、SSO登录、OAuth服务端等,单表100亿级项目验证 |
| NewLife.Agent | 2008 | 服务管理组件,把应用安装成为操作系统守护进程,Windows服务、Linux的Systemd |
| NewLife.Zero | 2020 | Zero零代脚手架,基于NewLife组件生态的项目模板NewLife.Templates,Web、WebApi、Service |
| 中间件 | 对接知名中间件平台 | |
| NewLife.Redis | 2017 | Redis客户端,微秒级延迟,百万级吞吐,丰富的消息队列,百亿级数据量项目验证 |
| NewLife.RocketMQ | 2018 | RocketMQ纯托管客户端,支持Apache RocketMQ和阿里云消息队列,十亿级项目验 |
| NewLife.MQTT | 2019 | 物联网消息协议,MqttClient/MqttServer,客户端支持阿里云物联网 |
| NewLife.IoT | 2022 | IoT标准库,定义物联网领域的各种通信协议标准规范 |
| NewLife.Modbus | 2022 | ModbusTcp/ModbusRTU/ModbusASCII,基于IoT标准库实现,支持ZeroIoT平台和IoTEdge网关 |
| NewLife.Siemens | 2022 | 西门子PLC协议,基于IoT标准库实现,支持IoT平台和IoTEdge |
| NewLife.Map | 2022 | 地图组件库,封装百度地图、高德地图、腾讯地图、天地图 |
| NewLife.Audio | 2023 | 音频编解码库,PCM/ADPCMA/G711A/G722U/WAV/AAC |
| 产品平台 | 产品平台级,编译部署即用,个性化自定义 | |
| Stardust | 2018 | 星尘,分布式服务平台,节点管理、APM监控中心、配置中心、注册中心、发布中心 |
| AntJob | 2019 | 蚂蚁调度,分布式大数据计算平台(实时/离线),蚂蚁搬家分片思想,万亿级数据量项目验证 |
| NewLife.ERP | 2021 | 企业ERP,产品管理、客户管理、销售管理、供应商管理 |
| CrazyCoder | 2006 | 码神工具,众多开发者工具,网络、串口、加解密、正则表达式、Modbus、MQTT |
| EasyIO | 2023 | 简易文件存储,支持分布式系统中文件集中存储。 |
| XProxy | 2005 | 产品级反向代理,NAT代理、Http代理 |
| HttpMeter | 2022 | Http压力测试工具 |
| GitCandy | 2015 | Git源代码管理系统 |
| SmartOS | 2014 | 嵌入式操作系统,完全独立自主,支持ARM Cortex-M芯片架构 |
| SmartA2 | 2019 | 嵌入式工业计算机,物联网边缘网关,高性能.NET8主机,应用于工业、农业、交通、医疗 |
| FIoT物联网平台 | 2020 | 物联网整体解决方案,建筑、环保、农业,软硬件及大数据分析一体化,单机十万级点位项目验证 |
| UWB高精度室内定位 | 2020 | 厘米级(10~20cm)高精度室内定位,软硬件一体化,与其它系统联动,大型展厅项目验证 |
新生命开发团队
新生命团队(NewLife)成立于2002年,是新时代物联网行业解决方案提供者,致力于提供软硬件应用方案咨询、系统架构规划与开发服务。
团队主导的80多个开源项目已被广泛应用于各行业,Nuget累计下载量高达400余万次。
团队开发的大数据中间件NewLife.XCode、蚂蚁调度计算平台AntJob、星尘分布式平台Stardust、缓存队列组件NewLife.Redis以及物联网平台FIoT,均成功应用于电力、高校、互联网、电信、交通、物流、工控、医疗、文博等行业,为客户提供了大量先进、可靠、安全、高质量、易扩展的产品和系统集成服务。
我们将不断通过服务的持续改进,成为客户长期信赖的合作伙伴,通过不断的创新和发展,成为国内优秀的IoT服务供应商。
新生命团队始于2002年,部分开源项目具有20年以上漫长历史,源码库保留有2010年以来所有修改记录
网站:https://newlifex.com
开源:https://github.com/newlifex
QQ群:1600800/1600838
微信公众号:
| 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 | net40 is compatible. net403 was computed. 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.0
- NewLife.Core (>= 10.10.2024.801-net40)
-
.NETFramework 4.5
- NewLife.Core (>= 11.14.2026.402)
-
.NETFramework 4.6.1
- NewLife.Core (>= 11.14.2026.402)
-
.NETStandard 2.0
- NewLife.Core (>= 11.14.2026.402)
-
.NETStandard 2.1
- NewLife.Core (>= 11.14.2026.402)
-
net10.0
- NewLife.Core (>= 11.14.2026.402)
-
net6.0
- NewLife.Core (>= 11.14.2026.402)
-
net7.0
- NewLife.Core (>= 11.14.2026.402)
-
net8.0
- NewLife.Core (>= 11.14.2026.402)
-
net9.0
- NewLife.Core (>= 11.14.2026.402)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NewLife.Agent:
| Package | Downloads |
|---|---|
|
NewLife.Extensions.Hosting.AgentService
为ASP.NET Core与Worker提供Agent托管集成,支持服务化部署与运维。 |
|
|
sljc_WebApi.Core
用于后台API服务包 |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on NewLife.Agent:
| Repository | Stars |
|---|---|
|
NewLifeX/Stardust
星尘,轻量级分布式服务框架。配置中心、集群管理、远程自动发布、服务治理。服务自动注册和发现,负载均衡,动态伸缩,故障转移,性能监控。
|
|
|
NewLifeX/NewLife.Net
单机吞吐2266万tps的网络通信框架
|
|
|
NewLifeX/XProxy
XProxy是一个代理服务器,内置有NAT、反向代理、直接代理、间接代理等。
|
| Version | Downloads | Last Updated |
|---|---|---|
| 10.15.2026.402 | 173 | 4/2/2026 |
| 10.15.2026.402-beta0903 | 117 | 4/2/2026 |
| 10.15.2026.313-beta1445 | 133 | 3/13/2026 |
| 10.15.2026.305-beta0001 | 126 | 3/5/2026 |
| 10.15.2026.201 | 300 | 2/1/2026 |
| 10.15.2026.201-beta0225 | 138 | 2/1/2026 |
| 10.14.2026.112-beta0712 | 181 | 1/12/2026 |
| 10.14.2026.102 | 224 | 1/2/2026 |
| 10.14.2026.102-beta1552 | 154 | 1/2/2026 |
| 10.14.2025.1113 | 430 | 11/13/2025 |
| 10.14.2025.1113-beta0106 | 343 | 11/13/2025 |
| 10.13.2025.1001 | 484 | 10/1/2025 |
| 10.13.2025.1001-beta1728 | 242 | 10/1/2025 |
| 10.13.2025.901 | 492 | 9/1/2025 |
| 10.13.2025.901-beta0240 | 248 | 9/1/2025 |
| 10.13.2025.824-beta1223 | 294 | 8/24/2025 |
| 10.13.2025.604 | 699 | 6/4/2025 |
| 10.13.2025.602-beta1643 | 257 | 6/2/2025 |
| 10.12.2025.401 | 826 | 4/1/2025 |
| 10.12.2025.401-beta0712 | 281 | 4/1/2025 |
增强Windows服务稳定性