[Mono-list] Linux 'services'

Jonathan Pryor jonpryor@vt.edu
Tue, 08 Jun 2004 20:05:16 -0400


On Tue, 2004-06-08 at 13:50, Bailo, John wrote:
> I write a lot of windows services in c#
>  
> Now that I am learning mono -- can you tell me:
>  
> 1. What is the equivalent for linux?

The nearest direct equivalent is a Unix daemon, of which I know of two
"styles" offhand.  The simplest style is just a program which is
detached from the terminal and is always running.  The easiest way to do
this in Mono would be to use a shell script:

	#!/bin/sh
	nohup mono mydaemon.exe > /tmp/mydaemon.log 2>&1 &

The "nohup" detaches the program from the terminal, the > redirects
standard output, and 2>&1 redirects standard error to standard output. 
The final "&" puts the program into the background, so that the program
returns.

I'm not sure how portable "nohup" is, but it's apparently part of IEEE
Std 1003.1-2001, so hopefully it exists everywhere.

See also:
http://lists.ximian.com/archives/public/mono-devel-list/2004-June/006282.html

The more complex style is to use a "super daemon" which knows how to
spawn other daemons on demand.  This is what inetd and xinetd do; you
can Google for them for more information.

Eventually, this should be encapsulated by Mono's
System.ServiceProcess.ServiceBase class, but this hasn't been completed
yet.

Check the mono-list and mono-devel-list archives for more information.

> 2. Does monodevelop have a template for Linux services?

Not that I know of.
 
> 3. Is there a tutorial or article you can point me to ?

Not really.  Hopefully I've provided enough information to feed Google.

 - Jon