Filipe Borges
Filipe Borges

Reputation: 2793

Is it possible to run a .NET Core app as Windows Service AND Linux deamon

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?

Upvotes: 14

Views: 3711

Answers (1)

Bruno Mondelo
Bruno Mondelo

Reputation: 148

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

Upvotes: 4

Related Questions