14

Is it possible to, using the same code, create an .NET Core application that can be run as a windows service and as a deamon on linux?

Do you have an example/proof of concept?

5
  • 1
    Windows Service support is very weak currently and a lot of questions query about it. Linux Daemon Support (whatever that is) is in the targets of post .NET Core RTM (assuming in the next release).
    – Thomas
    May 25, 2016 at 19:13
  • 2
    You can definately do it. Both environment can hook up with command line tools based tools ... what .NET Core definately masters as of today..
    – Thomas
    May 25, 2016 at 19:14
  • 1
    Linux daemons can be written in nearly anything, since they're essentially just disconnected processes with no user interface. If you can do what you need in .Net core, you should be able to run it as a Linux daemon. However the real question is "Can you do what you want with .Net core at all?" since it's really pretty limited at this point. Jul 19, 2016 at 14:28
  • 1
    You can refer to stackoverflow.com/questions/37432031/…
    – Cheng Duke
    Oct 12, 2016 at 5:49
  • 1
    RedHat: developers.redhat.com/blog/2017/06/07/… Aug 15, 2017 at 20:33

1 Answer 1

4

Linux daemon services can be in any language that could be executed on system.

Daemons can be executed using systemd (in Fedora: systemctl start name.service). To put your program on Linux Systemd services you should create a new .service file and move it into '/etc/systemd/system/'

The syntax of a service it is:

[Unit]
Description=The description of your service
After=previous services needed

[Service]
ExecStart=The program execution /sbin/helloworld.exe
ExecStop=The command given when killing the service

[Install]
WantedBy=services that needs your service

More information about Linux-Red Hat services and service modules: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.