dotnet / dotnet/AspNetCore.Docs
The article about hosting ASP.NET Core application on Linux systemd gives wrong example of service definition file
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 109
Description
### Description
The [example service definition file](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu#create-the-service-file) uses `KillSignal=SIGINT` however it does not actually work the way it is described. As the [comment](https://source.dot.net/#Microsoft.Extensions.Hosting.Systemd/SystemdLifetime.netcoreapp.cs,e85b1b79fc260afb) 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](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+815fe034-c9fc-aee3-a8b5-f2e860b30302)
Contributor guide
Assessment
This issue has not been assessed yet.