Porting a Windows service to Linux

I port the application that runs as a background service on Windows at startup, we port the application to Linux (SUSE Enterprise server), I am completely new to Linux. Can someone help me on how to do this. how

  • Should I create a linux executable
  • After creating the binary, what changes should be made to the linux startup files to run this executable
  • How can my service register a callback function to change or modify or send commands to my service when it starts.
+4
source share
2 answers
  • Yes, you must create a Linux binary. You can rephrase your question, as I doubt this is your answer :-)
  • Usually you should create the so-called init file, which is located in /etc/init.d. Novell has an online manual that you can use to create the file. Note that although the init file is common, the exact way to allow the use of the system varies depending on the distribution.
  • This will be a noticeable change for you. If you perform simple actions, such as reloading the configuration file, you can use the functionality of the signals, especially the SIGHUP / HUP signal, which is commonly used for this purpose. If you need advanced communication with your daemon, you can use a UNIX domain socket (think of it as a named pipe) or a network socket.

Another task you need to complete is to demonize your application. This is usually done using the first fork () of your process, and then redirects the stdin / stdout pipes to the child. For more information, read this document.

+3
source

See how-to-migrate-a-net-windows-service-application-to-linux-using-mono .

On Linux, deamons are simple background processes. No special control methods (for example, start() , stop() ) are used, as in Windows. Create your service as a simple (console) application and run it in the background. You can use a tool like daemonize to run the program as a Unix daemon.

+3
source

Source: https://habr.com/ru/post/1307571/


All Articles