Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
manison opened this issue Oct 31, 2024 · 0 comments

Comments

@manison
Copy link

manison commented Oct 31, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants