BWA
BWA

Reputation: 5764

.net core one code for service/daemon for Windows/Linux

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

Answers (2)

Leonard Lewis
Leonard Lewis

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

See also: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio

Upvotes: 1

rickjerrity
rickjerrity

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

Related Questions