Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to migrate a .NET Windows Service application to Linux using mono?

What would be the best approach to migrate a .NET Windows Service to Linux using mono? I've been trying to avoid executing the application as a scheduled command.

Is it possible to obtain a service/system daemon(in linux) like behavior?

like image 624
Raúl Roa Avatar asked Mar 12 '09 10:03

Raúl Roa


People also ask

Can Windows services run on Linux?

As noted by others, mono-service is a host to run services built with the ServiceProcess assembly. Services built for Windows can use this method to run unmodified under Linux. You can control the service by sending signals to the process (see man page).

How do I convert a Windows application to a Windows service?

Open VS, go to File > New and select Project. Now, select a new project from the dialog box and create a new . NET Framework console application (for example, Myexe) and add the below logic to test that this exe was called from Windows Service. Now, let's create a Windows Service using Visual Studio.


1 Answers

Under Linux, deamons are simple background processes. No special control methods (e.g start(), stop()) are used as in Windows. Build your service as a simple (console) application, and run it in the background. Use a tool like daemonize to run a program as a Unix daemon, and remember to specify mono as the program to be activated.

As noted by others, mono-service is a host to run services built with the ServiceProcess assembly. Services built for Windows can use this method to run unmodified under Linux. You can control the service by sending signals to the process (see man page).

like image 108
gimel Avatar answered Sep 22 '22 23:09

gimel