I donβt think there is a cross-platform solution for this. Sections are fairly platform specific, AFAIK.
For # 2, you can do this without any code changes if you want to run .NET Core under systemd . All you have to do is publish your application and then create a systemd unit file to describe your daemon. systemd will handle the launch, restart, and destruction of your applications.
The following is an example systemd file for starting an ASP.NET Core application as a service: https://docs.microsoft.com/en-us/aspnet/core/publishing/apache-proxy#monitoring-our-application p>
[Unit] Description=Example .NET Application [Service] WorkingDirectory=/var/aspnetcore/hellomvc ExecStart=/usr/bin/dotnet /var/aspnetcore/hellomvc/hellomvc.dll Restart=always RestartSec=10 SyslogIdentifier=dotnet-example User=apache Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target
source share