Skip to content

The article about hosting ASP.NET Core application on Linux systemd gives wrong example of service definition file #33989

@manison

Description

@manison

Description

The example service definition file uses KillSignal=SIGINT however it does not actually work the way it is described. As the comment for SystemdLifetime says:

systemd only sends SIGTERM to the service process, so we only listen for that signal.
Other signals (ex. SIGINT/SIGQUIT) will be handled by the default .NET runtime signal handler
and won't cause a graceful shutdown of the systemd service.

So what actually happens when using KillSignal=SIGINT is that the ASP.NET Core application is not shutdown gracefully and it leaves resources behind since they are not disposed properly. For example when the application listens on Unix socket then the socket is not deleted when the service ends and cannot be started again since the file already exists.

The next paragraph then suggests

Use TimeoutStopSec to configure the duration of time to wait for the app to shut down after it receives the initial interrupt signal. If the app doesn't shut down in this period, SIGKILL is issued to terminate the app.

however it is not understood how this could even work in light of the above information that SIGINT terminates the application abruptly.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/host-and-deploy/linux-nginx.md

Document ID

815fe034-c9fc-aee3-a8b5-f2e860b30302

Article author

@Rick-Anderson

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions