SystemdHostBuilderExtensions.AddSystemd(IServiceCollection) Method

Definition

Configures the lifetime of the IHost built from services to SystemdLifetime, provides notification messages for application started and stopping, and configures console logging to the systemd format when running as a systemd service.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddSystemd(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddSystemd(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddSystemd : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddSystemd (services As IServiceCollection) As IServiceCollection

Parameters

Returns

The services instance for chaining.

Remarks

This is context aware and will only activate if it detects the process is running as a systemd Service or if NOTIFY_SOCKET is set.

The console log formatter is enabled when the process is detected as a systemd service. The SystemdLifetime and SystemdNotifier are registered when NOTIFY_SOCKET is set or the process is detected as a systemd service.

The systemd service file must be configured with Type=notify to enable notifications. See https://www.freedesktop.org/software/systemd/man/systemd.service.html.

Applies to