4 Replies Latest reply on Feb 8, 2011 11:50 AM by dpbaker57

    Running Multiple JVMs as Windows Services on a Single System

    dpbaker57

      I'm looking having three separate instances as services on the same host. Each must be isolated from the others. So we can't run them in the same JVM. We are currently running four (or more) on Windows 2003/32bit with 4.0.5 using JavaService.

       

      We are moving to Windows 2008/64bit with 5.1.0. I am looking at the service.bat and jdosssvc.exe set up. It seems that to use the distributed setup I would have to copy the scripts to different names and edit them to call the appropriate scripts for each instance I want.

       

      Am I correct? If not how do you do this without renaming and editing?

      I would really like a method that is less human intensive and therefore less error prone.

        • 1. Re: Running Multiple JVMs as Windows Services on a Single System
          peterj

          Yes, you are correct - you copy and edit service.bat.

           

          You might, however, want to take a look at the service.bat that is included with the source code for JBoss in Action (http://www.manning.com/jamae). In ch15, if you run Ant with target 04, it generates two service.bat files to run two app server instances. If you look at the source for those service.bat files (ch15/src/service/windows/service.bat) you will see that the all of the necessary configuration information appears in env vars set at the start of the script. They are initally set to proiperty strings (that is ${...}) and the Ant build script replaces those with build properties.

          • 2. Re: Running Multiple JVMs as Windows Services on a Single System
            dpbaker57

            Thank you for the prompt reply.

             

            This begs the question of why? I come from a Unix background and I am used to doing things a bit differently. Since the service calls out to a batch file why not just pass the instance name as an argument to the batch file? Then all the unique configuration could be in a single file (ie instance.conf) that would be used to set up things before calling run.bat.

            • 3. Re: Running Multiple JVMs as Windows Services on a Single System
              peterj

              I was going to say that this could be easily done, but changed my mind (not that it can;t be done, but it is a little more work). But I first have to tell you how it works before you will understand the issue. Service.bat registers jbosssvc.exe as a service. Thus when the service starts, jbosssvc.exe runs. jbosssvc.exe in truns runs service.bat (or a renamed version thereof, provided you mad the approriate changes in service.bat). As far as I know there is no way to also specify a parameter to pass to service.bat.

               

              So, if you grabbed the source for jbosssvc.bat and made the appropriate changes, you could possibly do what you want. You would also want to change the service registration code in service.bat to paramerize the "instance" value (so that you could register instances with the single service.bat). And of course change service.bat to read in the instance configuration file. You might also have to play with the current working directory in jbosssvc.exe so that it can easily find the config files.

               

              But consider what I did - I have a single service.bat source file. I have various configurations that currently are in a single ant script but could easily be pulled into separate ant properties file. I run the ant script, which reads the properties files and builds the run-time service.bat files for me. I never edit the run-time service.bat files - if I need to make changes I modify the properties and regenerate the runtime files.

              1 of 1 people found this helpful
              • 4. Re: Running Multiple JVMs as Windows Services on a Single System
                dpbaker57

                This would mean either having ant on all the systems or some method of redistribution from the place we generate the files. We will have to talk this through as to which will work into our release process the smoothest. With our 4.0.5 installations we use JavaService. With it all the java settings and custom arguments end up buried in the registry but with our application the changes to the stuff in the registry are very infrequent. So I'm also looking at whether or not the current version of JavaService is an alternative. I know it had a bug in the past. I'm just not sure if that problem still exists in the current version.

                 

                Again thank you for your prompt replies.