[Opensim-dev] Feature Request ...

Michael Wright michaelwri22 at yahoo.co.uk
Sun Dec 21 23:45:07 UTC 2008


It is perfectly possible to make service wrappers without changing the main classes of the various opensim servers. As in the example that Stefan provided, you just don't call the  Work() method. You only need to call the Startup() method, as a windows service will continue to run until it is shutdown.

We do the above all the time, so I can asure you it works.

The service just won't read console input if you don't call the Work method, so there is no point redirecting it. 

But I believe that is your only option as I don't think you will get agreement to make the sort of changes you want, to the opensim classes.

Develope <Develope at Ashuan.de> wrote:

@ Stefan Andersson
2) To be able to do so, you should implement the services as 'wrappers',
separate applications that _use_ the Main Classes, not change or expand
on them, like for example for the grid service wrapper:
 
    partial class GridServ : ServiceBase
    {
        private GridServerBase m_gridApplication;

        protected override void OnStart(string[] args)
        {
            // Define working directory (For a service, this is set to
System dir by default...)
            Process pc = Process.GetCurrentProcess();
            string useDirectory = pc.MainModule.FileName.Substring(0,
pc.MainModule.FileName.LastIndexOf(@"\"));
            Directory.SetCurrentDirectory(useDirectory);
            log4net.Config.XmlConfigurator.Configure();
            m_gridApplication = new GridServerBase();
            m_gridApplication.Startup();
        }
   }
 
(This snippet taken from Tribal Medias proprietary service wrappers -
feel free to copy+paste.)
 
--- It is impossible to not change the main applications, cause they
all went into 
   public void Work()
        {
            m_console.Notice("Enter help for a list of commands\n");

            while (true)
            {
                m_console.Prompt();
            }
        }

 Holding a Service into a loop or in console.readline make the
OnStart() not responsable for the machine and nothing runs.

---  Is the System.ServiceProcess not implemented in Mono ? If so there
is no problem doing this. In my solution all executables are running as
service and doing well (Win 2003). I try to evaluate how it works in
mono.

--- My implementation is:
 Here is the first bad hack
     public /*abstract*/ class BaseOpenSimServer :
System.ServiceProcess.ServiceBase
  {
  ...
   public static void RunService(BaseOpenSimServer
pInstance, string[] args)
   {
   ...
   }
  ...
  }

 In case of Gridserver ...
        public static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            GridServerBase.RunService(new GridServerBase(), args);

            //GridServerBase app = new GridServerBase();

  //app.Startup();
  //app.Work();
        }
  Thats all.
--- You can now start your application with parameter '/Install' or
'/unistall' to create this service or to uninstall it.
--- You chose if it starts as a service and how its name an dependencies
only in app.config of the diffrent projects.
 If you dont want to run this as service switch in app.config.


Greetz

Kai


-----Original Message-----
From: opensim-dev-bounces at lists.berlios.de
[mailto:opensim-dev-bounces at lists.berlios.de] On Behalf Of Kyle Hamilton
Sent: Sonntag, 21. Dezember 2008 00:24
To: opensim-dev at lists.berlios.de
Subject: Re: [Opensim-dev] Feature Request ...

You can also use srvany.exe from Microsoft to turn any .exe into a
service.  http://www.iopus.com/guides/srvany.htm has information.

-Kyle H

On Sat, Dec 20, 2008 at 1:13 PM, Stefan Andersson
 wrote:
> Excellent! We really need windows service wrappers for the various
exe's.
>
> A couple of pointers:
>
> 1) Since this is (in practice) a windows-only project, you should
implement
> this as a 'forge' project;
> http://forge.opensimulator.org/gf/
>
> 2) To be able to do so, you should implement the services as
'wrappers',
> separate applications that _use_ the Main Classes, not change or
expand on
> them, like for example for the grid service wrapper:
>
>     partial class GridServ : ServiceBase
>     {
>         private GridServerBase m_gridApplication;
>
>         protected override void OnStart(string[] args)
>         {
>             // Define working directory (For a service, this is set to
> System dir by default...)
>             Process pc = Process.GetCurrentProcess();
>             string useDirectory = pc.MainModule.FileName.Substring(0,
> pc.MainModule.FileName.LastIndexOf(@"\"));
>             Directory.SetCurrentDirectory(useDirectory);
>             log4net.Config.XmlConfigurator.Configure();
>             m_gridApplication = new GridServerBase();
>             m_gridApplication.Startup();
>         }
>    }
>
> (This snippet taken from Tribal Medias proprietary service wrappers -
feel
> free to copy+paste.)
>
> 3) When you've done the wrappers, the next step is to add a method to
> communicate with the consoles. One way to go about it is to have the
service
> process redirect the console in and output to a named pipe, and then
supply
> a console app that listens/writes to those pipes.
>
> Best regards,
> Stefan Andersson
> Tribal Media AB
>
>
> ________________________________
> Date: Sat, 20 Dec 2008 19:53:32 +0100
> From: Develope at Ashuan.de
> To: Opensim-dev at lists.berlios.de
> Subject: [Opensim-dev] Feature Request ...
>
>
> Hi Friends,
>
>
>
> i wish to implement the feature to run all Gridcomponents (Userserver,
> Assetserver ....) as a Service.
>
> My work is now only to evaluate how easy or not it is ... it is easy
.. but
> ...
>
>
>
> I must add an Reference to the System.ServiceProcess in several
Project.
>
> Now my question ...
>
>
>
> Is there a Problem doing this?
>
> And second how do i include an reference into a .patch-File?
>
>
>
> Kai
>
>
>
> _______________________________________________
> Opensim-dev mailing list
> Opensim-dev at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/opensim-dev
>
>
_______________________________________________
Opensim-dev mailing list
Opensim-dev at lists.berlios.de
https://lists.berlios.de/mailman/listinfo/opensim-dev
_______________________________________________
Opensim-dev mailing list
Opensim-dev at lists.berlios.de
https://lists.berlios.de/mailman/listinfo/opensim-dev


       
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-dev/attachments/20081221/e40387ea/attachment-0001.html>


More information about the Opensim-dev mailing list