Reputation: 5764
On Windows there are windows services, on Linux there are daemons.
Is it possible write one code using .net core which works on Windows like a service and on Linux like a daemon? Or I must write different system dependent start code?
Upvotes: 1
Views: 501
Reputation: 503
See Worker Services (if you can now use .NET Core 3.x):
You can create one from the new Visual Studio 2019 Worker Service project template, or by using the .NET CLI:
dotnet new worker
Upvotes: 1
Reputation: 814
Services and *daemons (not demons) are simply ways for the OS to manage executables/scripts, so as long as the code is OS independent (like .NET core) you should be able to use the same code base.
Running an executable as a daemon/service will vary based on the operating system. As such, I've linked to some existing stack overflow questions that should help a little.
How do you create a Linux daemon from a .NET Core console application?
Create Windows service from executable
Upvotes: 2