[Mono-list] Re: mono-service

peter apvx95 at dsl.pipex.com
Wed Nov 2 15:01:22 EST 2005


Robert Jordan wrote:

> I'm attaching a init.d skeleton for mono-services, in the hope
> that this (not quite mono related) problem will settle down
> for a while.
>
> It's for SUSE, but it can be easily adapted to other distros.
>
> Robert

Hi Robert,

Sorry to be a pain, but I tried the script without any success.  I have 
SuSE 9.3 Pro.  Here's what I got:

*****************
peter at linux:~/MonoRemotingTest/RemoteSumsService/bin/Release> ls
InstallUtil.InstallLog  RemoteSumsService.exe
monoservice             RemoteSumsService.exe.config
monoservice~            remotesumsservice.InstallLog
RemoteSumsObject.dll    remotesumsservice.InstallState
peter at linux:~/MonoRemotingTest/RemoteSumsService/bin/Release> kdesu 
./monoservice start
peter at linux:~/MonoRemotingTest/RemoteSumsService/bin/Release> ps -eaf | 
grep RemoteSumsService
peter    10160  9475  0 19:55 pts/2    00:00:00 grep RemoteSumsService
peter at linux:~/MonoRemotingTest/RemoteSumsService/bin/Release>      
*****************
i.e. It didn't start.

Other info:

The lines that needed configuring in the script were altered as follows:

************************

/# configure this/
SERVICE_DRIVER=/usr/bin/mono-service
/# configure this as well/
SERVICE_ASSEMBLY=/home/peter/MonoRemotingTest/RemoteSumsService/bin/Release/RemoteSumsService.exe

**************************

The code in the service (which I developed in Windows - where it works 
OK) is:

*****************************

*using* System;
*using* System.Collections;
*using* System.ComponentModel;
*using* System.Data;
*using* System.Diagnostics;
*using* System.ServiceProcess;
*using* System.Runtime.Remoting;

*namespace* Msc.RemoteSums
{
	*public* *class* RemoteSumsService : System.ServiceProcess.ServiceBase
	{
		//// /*<summary>*/ /
		//// Required designer variable./
		//// /*</summary>*
		*private* System.ComponentModel.Container components = *null*;

		*public* RemoteSumsService()
		{
			/// This call is required by the Windows.Forms Component Designer./
			InitializeComponent();

			/// TODO: Add any initialization after the InitComponent call/
		}

		/// The main entry point for the process/
		*static* void Main()
		{
			System.ServiceProcess.ServiceBase[] ServicesToRun;
	
			/// More than one user Service may run within the same process. To add/
			/// another service to this process, change the following line to/
			/// create a second service object. For example,/
			////
			///   ServicesToRun = new System.ServiceProcess.ServiceBase[] {new RemoteSumsService(), new MySecondUserService()};/
			////
			ServicesToRun = *new* System.ServiceProcess.ServiceBase[] { *new* RemoteSumsService() };

			System.ServiceProcess.ServiceBase.Run(ServicesToRun);
		}

		//// /*<summary>*/ /
		//// Required method for Designer support - do not modify /
		//// the contents of this method with the code editor./
		//// /*</summary>*
		*private* void InitializeComponent()
		{
			components = *new* System.ComponentModel.Container();
			*this*.ServiceName = "RemoteSumsService";
		}

		//// /*<summary>*
		//// Clean up any resources being used./
		//// /*</summary>*
		*protected* *override* void Dispose( bool disposing )
		{
			*if*( disposing )
			{
				*if* (components != *null*) 
				{
					components.Dispose();
				}
			}
			*base*.Dispose( disposing );
		}

		//// /*<summary>*
		//// Set things in motion so your service can do its work./
		//// /*</summary>*
		*protected* *override* void OnStart(string[] args)
		{
			/// TODO: Add code here to start your service./
			RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
//
		}
 
		//// /*<summary>*
		//// Stop this service./
		//// /*</summary>*
		*protected* *override* void OnStop()
		{
			/// TODO: Add code here to perform any tear-down necessary to stop your service./
		}
	}
}

********************

Have I missed something obvious (again)?

Thanks


Peter



More information about the Mono-list mailing list