I'm used to creating Windows services using Topshelf. With .NET Core and the prospect of going cross-platform, this raises a number of interesting scenarios:
The above is mainly just context. For the purpose of this question, I'd like to know what steps I need to take in order to run the equivalent of a Windows service on Linux, using .NET Core. If this can be done in a unified way across the platforms, even better.
NET Core runtime allows you to run applications on Linux that were made with .
I dont think there is a cross platform solution for this. Sevices are pretty platform specific, AFAIK.
For # 2, you should be able to do this without any code changes if you want run .NET Core under systemd. All you basically need to do is publish your application, and then create a systemd unit file to describe your daemon. systemd will then handle starting, restarting and killing your applications.
There is an example of a systemd unit file here to run a ASP.NET Core application as a service: https://docs.microsoft.com/en-us/aspnet/core/publishing/apache-proxy#monitoring-our-application
[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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With