dasMulli / dotnet-win32-service

Helper classes to set up and run as windows services directly on .net core. A ServiceBase alternative.
MIT License
451 stars 57 forks source link

How to run this as a daemon on linux #66

Closed ayappant closed 6 years ago

ayappant commented 6 years ago

How should I get this working as daemon on linux? Any samples would help

"Build truly portable applications that can for example run as service on windows and as daemon on linux, just using runtime checks / switches"

Trapov commented 6 years ago

@ayappant, hi there, I believe you don't need this library if your application only runs on Linux. Here's a simple guide how to do so (Go to the link)

That means you have to do checks for each platform yourself, at a runtime.

using runtime checks / switches

And if you really want to target both platforms, then you would write something like this, i guess:

if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
    // your code to handle the control to this library
}
// since Linux doesn't need any daemon-specific code just do your normal code
dasMulli commented 6 years ago

@ayappant exactly like @Trapov said, a cross-platform "service" would only use this specific library for windows-specific parts.

Running as a linux daemon that starts and stops should already be possible with classic console applications, though more sophisticated control logic is probably blocked on proper signal handling. Also see https://github.com/dotnet/corefx/issues/25384

Closing as out of scope.