Skip to main content
net10.0net5.0net6.0net7.0net8.0net9.0

为ASP.NET Core与Worker提供Agent托管集成,支持服务化部署与运维。

Published
Oct 19, 2026
yesterday
Total Downloads
41.7K
41,672

Install

dotnet add package NewLife.Extensions.Hosting.AgentService --version 10.17.2026.1019-beta1541
ProductVersions
.NET
net10.0net5.0net6.0net7.0net8.0net9.0
Other
.NETCoreApp3.1

README

NewLife.Agent - Cross-Platform Service Daemon & Ops Framework

GitHub top language

GitHub License NuGet Downloads NuGet NuGet prerelease test locales platform arch contributors

🌐 简体中文 | 繁體中文 | Español | Deutsch | 日本語 | Français | Português | Русский | 한국어 | العربية

Tutorial: https://newlifex.com/core/agent


Overview

NewLife.Agent is a service-oriented framework for long-running applications. It enables console/Web/Worker programs to be quickly hosted as operating system services, and provides unified install, start/stop, monitoring, restart, and troubleshooting capabilities.

Supported platforms:

  • Windows (Service / startup at login)
  • Linux (Systemd / Procd / RcInit, etc.)
  • macOS (LaunchAgent)

Supported frameworks:

  • NewLife.Agent: net40;net45;net461;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0;net9.0;net10.0
  • NewLife.Extensions.Hosting.AgentService: netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0

Highlights

  • Integrated Development and Operations: Inherit ServiceBase to gain full service governance capabilities.
  • Built-in Web Dashboard: A lightweight management panel for viewing status and performing operations in a browser, with extension panels and theme switching, built-in token authentication and brute-force protection; it listens on localhost by default (WebBind can expose it to the LAN).
  • Cross-Platform Auto-Adaptation: Automatically selects the most suitable host implementation per operating system.
  • NativeAOT Native Publishing Support: Built-in commands and the Web dashboard are fully adapted for trimming/AOT; net8.0+ builds produce zero IsAotCompatible warnings, and CI covers 12 RIDs: 9 targets run real smoke tests (8 native targets + linux-loongarch64 under QEMU user-mode emulation), while cross targets (linux-arm/linux-musl-arm/linux-musl-arm64) get publish verification.
  • Multi-Architecture Unit Tests: win-x64 / linux-x64 / linux-arm64 run natively, and linux-loongarch64 (Loongson) runs the full test suite under QEMU user-mode emulation; triggered by push/PR and supports manual runs.
  • Built-in Command System: Supports -install/-start/-stop/-restart/-status/-run.
  • Health Monitoring & Self-Healing: The HealthMonitor component provides memory/thread/handle thresholds, scheduled restarts, and WatchDog health checks.
  • Multi-Instance Friendly: Configure different ServiceName values to deploy multiple instances of one program.
  • Host Integration Extension Package: Bring ASP.NET Core/Worker applications under unified service lifecycle management.

Getting Started

1) Minimal Service

Inherit ServiceBase and call Main(args) at the entry point:

  • Override StartWork(String reason) to start your business logic
  • Override StopWork(String reason) to stop and clean up resources

2) Command-Line Operations

Common commands:

  • -i: Install the service
  • -install: Install and start the service
  • -start: Start the service
  • -stop: Stop the service
  • -restart: Restart the service
  • -status: View service status
  • -u: Uninstall the service
  • -uninstall: Stop and uninstall the service
  • -run: Run in console mode (for debugging)

Install/uninstall/start/stop typically require Administrator (Windows) or root (Linux) privileges.

3) ASP.NET Core / Worker Integration

Reference NewLife.Extensions.Hosting.AgentService and call UseAgentService() on your HostBuilder to bridge the generic host lifecycle with Agent service governance.


Documentation


Quick Install

dotnet new install NewLife.Templates
dotnet new service --name agent
cd agent
dotnet run

NewLife Project Matrix

All projects target net9.0/netstandard2.1/netstandard2.0/net4.62/net4.5 by default; the legacy version (2024.0801) supports net4.0/net2.0.

Project Year Description
Core Components Foundation for middleware and products
NewLife.Core 2002 Core library — logging, config, caching, networking, serialization, APM tracing
NewLife.XCode 2005 Big data ORM — 10B+ rows per table, MySQL/SQLite/SQL Server/Oracle/PostgreSQL/DaMeng, auto-sharding, read/write splitting
NewLife.Net 2005 Network library — 22.66M tps per node, 4M concurrent TCP long connections per node
NewLife.Remoting 2011 Protocol communication library — CS application communication framework with HTTP/RPC support, high throughput, low overhead and easy access for IoT devices
NewLife.Cube 2010 Rapid development platform — user permissions, SSO, OAuth server, verified at 10B+ row scale
NewLife.Agent 2008 Service management — install apps as OS daemons, Windows Services, Linux Systemd
NewLife.Zero 2020 Zero scaffolding — project templates (Web, WebApi, Service) based on NewLife ecosystem
Middleware Integration with major middleware platforms
NewLife.Redis 2017 Redis client — microsecond latency, million-level throughput, rich message queues, verified at 10B+ row scale
NewLife.RocketMQ 2018 Fully managed RocketMQ client — Apache RocketMQ & Alibaba Cloud MQ, verified at 1B+ scale
NewLife.MQTT 2019 MQTT — MqttClient/MqttServer, Alibaba Cloud IoT support
NewLife.IoT 2022 IoT standard library — protocol specifications for IoT domain
NewLife.Modbus 2022 Modbus — ModbusTcp/ModbusRTU/ModbusASCII, ZeroIoT & IoTEdge support
NewLife.Siemens 2022 Siemens PLC protocol — IoT platform & IoTEdge support
NewLife.Map 2022 Map components — Baidu, AMap, Tencent, Tianditu
NewLife.Audio 2023 Audio codec — PCM/ADPCMA/G711A/G722U/WAV/AAC
Products Production-ready platforms
Stardust 2018 Distributed service platform — node management, APM, config center, registry, release center
AntJob 2019 Distributed big data compute — real-time & offline, ant-colony sharding, verified at trillion-row scale
NewLife.ERP 2021 Enterprise ERP — product, customer, sales, supplier management
CrazyCoder 2006 Developer toolkit — networking, serial, encryption, regex, Modbus, MQTT
EasyIO 2023 Simple file storage — centralized file storage for distributed systems
XProxy 2005 Production reverse proxy — NAT proxy, HTTP proxy
HttpMeter 2022 HTTP stress testing tool
GitCandy 2015 Git source code management
SmartOS 2014 Embedded OS — fully independent, ARM Cortex-M
SmartA2 2019 Embedded industrial computer — IoT edge gateway, .NET 8, industrial/agricultural/transportation/medical
FIoT Platform 2020 IoT total solution — integrated software, hardware and big-data analytics for construction, environmental protection and agriculture, verified in a single-machine 100K+ point project
UWB Indoor Positioning 2020 Centimeter-level (10~20cm) high-precision indoor positioning — integrated hardware/software, interoperates with other systems, verified in large exhibition hall projects

NewLife Team

XCode

The NewLife team, founded in 2002, is a new-era IoT industry solution provider dedicated to software/hardware application consulting, system architecture planning, and development services. The team's 80+ open-source projects have been widely used across industries, with cumulative NuGet downloads exceeding 4 million. Flagship products developed by the team — NewLife.XCode big data middleware, AntJob distributed computing platform, Stardust distributed platform, NewLife.Redis cache queue component, and the FIoT IoT platform — have been successfully deployed in power, education, internet, telecommunications, transportation, logistics, industrial control, healthcare, and cultural heritage sectors, delivering a large number of advanced, reliable, secure, high-quality, and easily extensible products and system integration services to customers.

We will continuously improve our services to become a long-term trusted partner of our customers, and through continuous innovation and development, become an excellent domestic IoT service provider.

The NewLife team started in 2002; some open-source projects have a history of more than 20 years, and the source repository retains all modification records since 2010. Website: https://newlifex.com GitHub: https://github.com/newlifex QQ Group: 1600800/1600838 WeChat Official Account: 智能大石头

Changes from Previous Version

No structural changes between v10.17.2026.1019-beta0429 and v10.17.2026.1019-beta1541.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 7 target frameworks; confirm the exact target used by your application.The published metadata declares 21 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.