Skip to main content
net8.0net9.0.NETStandard2.1

.NET hosting infrastructure for Systemd Services.

Published
Jun 11, 2024
2y ago
Total Downloads
21.1M
21,097,183

Install

dotnet add package Microsoft.Extensions.Hosting.Systemd --version 9.0.0-preview.5.24306.7
ProductVersions
.NET
net8.0net9.0
.NET Standard
netstandard2.1

README

About

Provides an implementation for hosting an application as a Linux systemd service.

The package ensures proper communication between .NET applications and systemd, making it easier to build, deploy, and run applications as Linux services.

Key Features

  • Systemd service integration
  • Health check support
  • Logging and diagnostics with different log levels
  • Notify systemd on application state changes

How to Use

Wherever you configure your host, add the UseSystemd method to the builder chain:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .UseSystemd() // Enable running as a Systemd service
        .ConfigureServices((hostContext, services) =>
        {
            ...
        });

The UseSystemd method will no-op when not running as a daemon, allowing normal debugging or production use both with and without systemd.

Registering the service requires a special file, called a unit file, to be added to the /etc/systemd/system directory.

For more information on this part, check the run your app as a Linux service with systemd guide.

Main Types

The main types provided by this library are:

  • Microsoft.Extensions.Hosting.Systemd.SystemdNotifier
  • Microsoft.Extensions.Hosting.Systemd.SystemdLifetime
  • Microsoft.Extensions.Hosting.SystemdHostBuilderExtensions

Additional Documentation

Related Packages

Feedback & Contributing

Microsoft.Extensions.Hosting.Systemd is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Changes from Previous Version

No structural changes between v9.0.0-preview.4.24266.19 and v9.0.0-preview.5.24306.7.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

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