Writing services for Linux
This book has mentioned background processes quite a lot. We’ve seen how to write them and how to deploy them. But how does that work on Linux? Let’s find out!
A background service in Linux is called a daemon. This software runs in the background and doesn’t immediately interact with a user. That sounds like something we, as system programmers, should recognize.
We can create a Worker Service in Visual Studio to write such software. Build it, then deploy it to a folder on your Linux distro.
The service description
Before you do that, add a new file to the project; this is the system description that Linux needs to register your services.
I called my file crossplatformservice.service
. It looks like this:
[Unit] Description=My .NET Core Worker Service After=network.target [Service] WorkingDirectory=/home/dvroegop/service ExecStart=/usr/bin/dotnet /home/dvroegop/service/14_CrossPlatformService.dll Restart=always # Restart...