by
cc0028
@ 2005-11-03 - 20:52:48
One of the things you need to do in order to expose remote objects on an application server is to provide a host for the object. The host listens for communications on a specified port and then creates the object that the client specifies in the communication. In .NET this is done via a URI, which is a generalisation of the kind of string you type into a web browser to find a particular web page:
<protocol>://path/to/the/resource
For a web page, the protocol is http, usually, but for remoting it can be other things like tcp (transport control protocol). But I digress.
If you want to, you can use an ordinary program that you start manually as the host for the remote object, but this has a number of drawbacks. Firstly and most obviously, you have to start it manually. Secondly and not quite so obviously, you have to be logged in in order to start the program. Furthermore, the program is likely running in the foreground (e.g. in a terminal window), so it could accidentally be terminated.
What we would really like is to host the object in a program that starts automatically when the server boots and continues to run in the background without any user intervention. This type of program is called a "Service" in Windows, or a "Daemon" in the Unix/Linux world.
The Windows version of .NET provides a lot of help to allow you to host your remote object in a Windows service - including Installer objects that you can include in assemblies containing class(es) derived from ServiceProcess.ServiceBase, and which can be used by a .NET tool called installutil to install the Windows service.
The Mono team have managed to transfer much of this to a Unix/Linux environment: but the process is a little different. You have to use a tool called mono-service whose usage is not immediately obvious - to me at any rate.
Thankfully Robert Jordan and Jörg Rosenkranz from the Mono mailing list provided me with enough help and advice to see me through. Robert, in particular, provided me with a script that installs the service by calling mono-service with the required parameters.
I had a lot of trouble getting it to work even then, until Jörg suggested i check /var/log/messages to see what was being output (Doh!). It gave a perfectly clear message telling me that I had an element attribute mis-configured in my app.config file. Windows requires:
<customErrors mode="Off">
Mono required:
<customErrors mode="off">
Spot the difference? It's the difference between a small and a capital 'O'.
Robert has now made Mono case insensitive, but my installation has not yet been updated with his patch.
I'm still not done, though. The above means I can start the daemon process in the background such that it will persist even if I log off. At the moment there is nothing to make it start when the machine is switched on. I've asked for advice and expect this will not be a problem. I don't think so, anyway.