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:
- Given that Topshelf does not yet support .NET Core, how can I create Windows services for .NET Core? (One approach could be to create a regular .NET Core console application and install it with NSSM, but that doesn't provide hooks for Start/Stop, so there is no way to gracefully stop the service).
- How do you do the same thing on Linux? There are no Windows services, but there is the concept of daemon processes. This answer provides a basic approach, but requires additional work and depends on certain underlying software.
- Can #1 and #2 above be done using a cross-platform approach, or is it necessary to tackle this per platform (e.g. with preprocessor directives)?
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.