views:

72

answers:

2

I am porting an application which runs as a background service in windows at startup, we are porting the application to linux(SUSE Enterprise server), I'am completely new to linux. Can somebody help me on how to proceed with this. Like

  1. Should I build the linux executable
  2. After builiding the binary, what changes should I make to linux startup files to run this executable
  3. How my service can register call back function to modify or change or send commands to my service while it is running
+2  A: 

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

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. You can use a tool like daemonize to run a program as a Unix daemon.

gimel
+2  A: 
  1. Yes, you should build a Linux binary. You may want to rephrase your question since I doubt this is the answer you want :-)
  2. You should generally create what is known as an "init" file, which lives in /etc/init.d. Novell has a guide online which you can use to author the file. Note that while the init file is common, the exact method of letting the operating system use it varies depending on the distribution.
  3. This is going to be a marked change for you. If you are doing simple actions such as re-loading a configuration file, you can use the signals functionality, especially the SIGHUP/HUP signal which is generally used for this purpose. If you require extended 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 are going to need to accomplish is to daemonize your application. Generally this is done by first fork()ing your process, then redirecting the stdin/stdout pipes in the child. There are more details which can be answered by reading this document

Yann Ramin