Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 888
Filipe Borges Avatar asked May 25 '16 16:05

Filipe Borges


1 Answers

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

like image 124
Bruno Mondelo Avatar answered Nov 09 '22 11:11

Bruno Mondelo