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

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

Published
Oct 21, 2026
today
Total Downloads
41.7K
41,672

Install

dotnet add package NewLife.Extensions.Hosting.AgentService --version 10.17.2026.1021-beta0235
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

Ecosystem Map

NewLife is a layered ecosystem of independently versioned open-source projects. The map below is shared verbatim by every NewLife repository; each project links to its repository and its primary NuGet package.

Project What it does Downloads
Foundation
NewLife.Core Logging, configuration, caching, networking, serialization, scheduling and APM tracing. NuGet
NewLife.XCode Data middleware: single tables at the tens-of-billions scale, automatic sharding, read-write splitting, 10+ databases. NuGet
NewLife.Net High-performance network library: 1.77M pps / 14.5 Gbps on a single machine (TCP 1KB, 2026-10), 4M long-lived TCP connections. NuGet
NewLife.Remoting Protocol communication and RPC framework for client/server applications and IoT devices. NuGet
NewLife.Agent Installs .NET applications as OS daemons: Windows services and Linux systemd. NuGet
NewLife.Templates dotnet new project templates for console, web, API, service, data and IoT projects. NuGet
Data & Messaging
NewLife.Redis Redis client with microsecond latency, millions of ops/s and built-in message queues. NuGet
NewLife.RocketMQ Pure managed RocketMQ client for Apache RocketMQ and Alibaba Cloud Message Queue. NuGet
NewLife.MQTT MQTT client and server, including Alibaba Cloud IoT connectivity. NuGet
NewLife.NovaDb Hybrid database in C#: embedded or networked, relational, time-series, message queue and KV in one. NuGet
NewLife.MySql MySql driver and helper layer built on the NewLife data stack. NuGet
Web, AI & Distributed
NewLife.Cube Rapid admin-platform framework: permissions, SSO, OAuth server and CRUD scaffolding. NuGet
Stardust Distributed service platform: node management, APM, configuration center, registry and release center. NuGet
AntJob Distributed task and real-time data scheduling platform with sharding, retries and backfill. NuGet
NewLife.AI Unified client for 46 LLM providers plus ChatAI, a ready-to-run web chat application. NuGet
Industrial & IoT
NewLife.IoT IoT standard library defining protocol contracts and device abstractions. NuGet
NewLife.Modbus Modbus TCP/RTU/ASCII implementation on top of NewLife.IoT. NuGet
NewLife.Siemens Siemens PLC protocol on top of NewLife.IoT. NuGet
NewLife.Omron Omron PLC protocol on top of NewLife.IoT. NuGet
NewLife.Melsec Mitsubishi Melsec PLC protocol on top of NewLife.IoT. NuGet
NewLife.OPC OPC client for industrial data access. —
NewLife.BACnet BACnet building-automation protocol stack. NuGet
ZeroIoT Lightweight open-source IoT platform with gateway and device management. —
Vehicle Telematics
NewLife.JT808 JT/T 808 vehicle positioning protocol: 70+ message bodies, 2011/2013/2019. NuGet
NewLife.JT809 JT/T 809 platform-to-platform protocol for transport authorities. NuGet
NewLife.JT1078 JT/T 1078 in-vehicle video: RTP parsing, FLV/fMP4 remuxing and live streaming. NuGet
Domain Components
NewLife.Office One package for Excel, Word, PPT, PDF and 15+ document formats. NuGet
NewLife.Audio Cross-platform audio: codecs, device I/O, DSP, containers and streaming. NuGet
NewLife.Video Video codecs, container formats, frame processing and streaming. NuGet
NewLife.Map Unified interface over Baidu, AMap, Tencent and Tianditu with geocoding and coordinate conversion. NuGet
NewLife.IP IPv4 geolocation with an offline memory-mapped database and an online API fallback. NuGet
Tools & Products
CrazyCoder Developer toolbox: network, serial port, crypto, regex, Modbus and MQTT. NuGet
GitCandy Self-hosted Git source code management system. —
LuckyClover Installs the matching .NET runtime automatically when launched from an older host. —

Badges show the primary package of each project; theme, extension and satellite packages are listed on their NuGet pages.The 30+ packages not listed here (FTP, LoRa, Office extensions, protocol drivers and more) are available under the NewLifeX organization and on newlifex.com.


Team

Founded in 2002, the NewLife team has spent more than two decades on the .NET and IoT ecosystem, maintains nearly 100 open-source projects (34 of them core to this map), and delivers integrated software and hardware solutions for power, logistics, healthcare, industrial control and internet industries. We live by the motto "learning has no seniority — mastery earns respect".

Open-source components have been downloaded 6.48M times from NuGet (ecosystem-wide, as of 2026-10).

Website: https://newlifex.com · Open source organization: https://github.com/NewLifeX

WeChat Official Account: 智能大石头 (scan to follow)

智能大石头

Changes from Previous Version

No structural changes between v10.17.2026.1020-beta1532 and v10.17.2026.1021-beta0235.

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.