Before doing this kind of cooking, better spending time to make the system usable. <div><br></div><div>Questions:</div><div>how the user will access to the console in your service mode ?</div><div>how could he see any errors / dump ?</div>
<div><br></div><div>SM</div><div><br><div><br><div class="gmail_quote">On Sun, Dec 21, 2008 at 8:31 AM, Develope <span dir="ltr"><<a href="mailto:Develope@ashuan.de">Develope@ashuan.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
thank you for answering so fast ...<br>
<br>
@Kyle Hamilton<br>
1. You can also use srvany.exe from Microsoft to turn any .exe into a<br>
<div class="Ih2E3d">service.  <a href="http://www.iopus.com/guides/srvany.htm" target="_blank">http://www.iopus.com/guides/srvany.htm</a> has information.<br>
<br>
</div>---     If you do that, you are not able to control your service like<br>
OnStart(). The Memoryallocation in "real" Services (ServiceBase) is much<br>
faster  than them doing under srvany. There are many other drawbacks<br>
using srvany.exe (Logging, dependencies, rightsmanagement, installation<br>
...)<br>
<br>
@ Stefan Andersson<br>
<div class="Ih2E3d">2) To be able to do so, you should implement the services as 'wrappers',<br>
separate applications that _use_ the Main Classes, not change or expand<br>
on them, like for example for the grid service wrapper:<br>
<br>
    partial class GridServ : ServiceBase<br>
    {<br>
        private GridServerBase m_gridApplication;<br>
<br>
        protected override void OnStart(string[] args)<br>
        {<br>
            // Define working directory (For a service, this is set to<br>
System dir by default...)<br>
            Process pc = Process.GetCurrentProcess();<br>
            string useDirectory = pc.MainModule.FileName.Substring(0,<br>
pc.MainModule.FileName.LastIndexOf(@"\"));<br>
            Directory.SetCurrentDirectory(useDirectory);<br>
            log4net.Config.XmlConfigurator.Configure();<br>
            m_gridApplication = new GridServerBase();<br>
            m_gridApplication.Startup();<br>
        }<br>
   }<br>
<br>
(This snippet taken from Tribal Medias proprietary service wrappers -<br>
feel free to copy+paste.)<br>
<br>
</div>---     It is impossible to not change the main applications, cause they<br>
all went into<br>
          public void Work()<br>
        {<br>
            m_console.Notice("Enter help for a list of commands\n");<br>
<br>
            while (true)<br>
            {<br>
                m_console.Prompt();<br>
            }<br>
        }<br>
<br>
        Holding a Service into a loop or in console.readline make the<br>
OnStart() not responsable for the machine and nothing runs.<br>
<br>
---  Is the System.ServiceProcess not implemented in Mono ? If so there<br>
is no problem doing this. In my solution all executables are running as<br>
service and doing well (Win 2003). I try to evaluate how it works in<br>
mono.<br>
<br>
--- My implementation is:<br>
        Here is the first bad hack<br>
            public /*abstract*/ class BaseOpenSimServer :<br>
System.ServiceProcess.ServiceBase<br>
                {<br>
                ...<br>
                        public static void RunService(BaseOpenSimServer<br>
pInstance, string[] args)<br>
                        {<br>
                        ...<br>
                        }<br>
                ...<br>
                }<br>
<br>
        In case of Gridserver ...<br>
        public static void Main(string[] args)<br>
        {<br>
            XmlConfigurator.Configure();<br>
<br>
            GridServerBase.RunService(new GridServerBase(), args);<br>
<br>
            //GridServerBase app = new GridServerBase();<br>
<br>
                //app.Startup();<br>
                //app.Work();<br>
        }<br>
                Thats all.<br>
---     You can now start your application with parameter '/Install' or<br>
'/unistall' to create this service or to uninstall it.<br>
--- You chose if it starts as a service and how its name an dependencies<br>
only in app.config of the diffrent projects.<br>
        If you dont want to run this as service switch in app.config.<br>
<br>
<br>
Greetz<br>
<br>
Kai<br>
<div class="Ih2E3d"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:opensim-dev-bounces@lists.berlios.de">opensim-dev-bounces@lists.berlios.de</a><br>
[mailto:<a href="mailto:opensim-dev-bounces@lists.berlios.de">opensim-dev-bounces@lists.berlios.de</a>] On Behalf Of Kyle Hamilton<br>
Sent: Sonntag, 21. Dezember 2008 00:24<br>
To: <a href="mailto:opensim-dev@lists.berlios.de">opensim-dev@lists.berlios.de</a><br>
</div><div><div></div><div class="Wj3C7c">Subject: Re: [Opensim-dev] Feature Request ...<br>
<br>
You can also use srvany.exe from Microsoft to turn any .exe into a<br>
service.  <a href="http://www.iopus.com/guides/srvany.htm" target="_blank">http://www.iopus.com/guides/srvany.htm</a> has information.<br>
<br>
-Kyle H<br>
<br>
On Sat, Dec 20, 2008 at 1:13 PM, Stefan Andersson<br>
<<a href="mailto:stefan@tribalmedia.se">stefan@tribalmedia.se</a>> wrote:<br>
> Excellent! We really need windows service wrappers for the various<br>
exe's.<br>
><br>
> A couple of pointers:<br>
><br>
> 1) Since this is (in practice) a windows-only project, you should<br>
implement<br>
> this as a 'forge' project;<br>
> <a href="http://forge.opensimulator.org/gf/" target="_blank">http://forge.opensimulator.org/gf/</a><br>
><br>
> 2) To be able to do so, you should implement the services as<br>
'wrappers',<br>
> separate applications that _use_ the Main Classes, not change or<br>
expand on<br>
> them, like for example for the grid service wrapper:<br>
><br>
>     partial class GridServ : ServiceBase<br>
>     {<br>
>         private GridServerBase m_gridApplication;<br>
><br>
>         protected override void OnStart(string[] args)<br>
>         {<br>
>             // Define working directory (For a service, this is set to<br>
> System dir by default...)<br>
>             Process pc = Process.GetCurrentProcess();<br>
>             string useDirectory = pc.MainModule.FileName.Substring(0,<br>
> pc.MainModule.FileName.LastIndexOf(@"\"));<br>
>             Directory.SetCurrentDirectory(useDirectory);<br>
>             log4net.Config.XmlConfigurator.Configure();<br>
>             m_gridApplication = new GridServerBase();<br>
>             m_gridApplication.Startup();<br>
>         }<br>
>    }<br>
><br>
> (This snippet taken from Tribal Medias proprietary service wrappers -<br>
feel<br>
> free to copy+paste.)<br>
><br>
> 3) When you've done the wrappers, the next step is to add a method to<br>
> communicate with the consoles. One way to go about it is to have the<br>
service<br>
> process redirect the console in and output to a named pipe, and then<br>
supply<br>
> a console app that listens/writes to those pipes.<br>
><br>
> Best regards,<br>
> Stefan Andersson<br>
> Tribal Media AB<br>
><br>
><br>
> ________________________________<br>
> Date: Sat, 20 Dec 2008 19:53:32 +0100<br>
> From: Develope@Ashuan.de<br>
> To: <a href="mailto:Opensim-dev@lists.berlios.de">Opensim-dev@lists.berlios.de</a><br>
> Subject: [Opensim-dev] Feature Request ...<br>
><br>
><br>
> Hi Friends,<br>
><br>
><br>
><br>
> i wish to implement the feature to run all Gridcomponents (Userserver,<br>
> Assetserver ....) as a Service.<br>
><br>
> My work is now only to evaluate how easy or not it is ... it is easy<br>
.. but<br>
> ...<br>
><br>
><br>
><br>
> I must add an Reference to the System.ServiceProcess in several<br>
Project.<br>
><br>
> Now my question ...<br>
><br>
><br>
><br>
> Is there a Problem doing this?<br>
><br>
> And second how do i include an reference into a .patch-File?<br>
><br>
><br>
><br>
> Kai<br>
><br>
><br>
><br>
> _______________________________________________<br>
> Opensim-dev mailing list<br>
> <a href="mailto:Opensim-dev@lists.berlios.de">Opensim-dev@lists.berlios.de</a><br>
> <a href="https://lists.berlios.de/mailman/listinfo/opensim-dev" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-dev</a><br>
><br>
><br>
_______________________________________________<br>
Opensim-dev mailing list<br>
<a href="mailto:Opensim-dev@lists.berlios.de">Opensim-dev@lists.berlios.de</a><br>
<a href="https://lists.berlios.de/mailman/listinfo/opensim-dev" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-dev</a><br>
_______________________________________________<br>
Opensim-dev mailing list<br>
<a href="mailto:Opensim-dev@lists.berlios.de">Opensim-dev@lists.berlios.de</a><br>
<a href="https://lists.berlios.de/mailman/listinfo/opensim-dev" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-dev</a><br>
</div></div></blockquote></div><br></div></div>