3 Replies Latest reply on Jan 9, 2012 2:52 PM by nmitchell

    Delay JBoss Services when running in Cluster

    nmitchell Newbie

      I have an environment setup with a clustered JBoss 5.1.0 installation contianing 5 nodes.  Each node is running the same application, but for a different client.  We have these installed as a service using an unique service.bat for each node that contains port bindings, etc.  All the services are set to start up automatically when windows boots.  When the server boots, 4 nodes start, and 1 errs out.  Typically it is the second node that tries to start that errs out.  What's causing this is that the first service still has a lock on a temporary file when the second service tries to start.  This prevents the second service from being able to access the file, and hence bombs the service startup. 

       

      I've been digging around for some time trying to find a way to add a custom delay into each service installation.  Ive figured through manual testing that by pausing 15 seconds between each service startup I can prevent this from happening.  Is there a way to add a delay into my service install?  If not, is it possible for me to access the JBossSVC.exe source code so that I can add additional parameters in myself?

       

      If anyone has any other ideas on how to achieve this, I am all ears. 

        • 1. Re: Delay JBoss Services when running in Cluster
          Peter Johnson Master

          You do have a separate copy of service.bat for each service, right? And you have modified each of the service.bat files such that they don't conflict (that is, they each use different lock files and redirect stderr/stdout to different log files? If not, check out how I did it for JBoss in Action (http://www.manning.com/jamae), download the source code and look at ch15/src/service/windows/service.bat. And notice how the Ant ch15/build.xml script uses this template to create two separate service.bat files.

           

          However, if the file in question is one used by your apps, and they all need access to the same file, then you could add a delay into the service.bat file to have it wait 15, 30, 45, etc. seconds before launching jbosssvc.exe.

          • 2. Re: Delay JBoss Services when running in Cluster
            nmitchell Newbie

            That is correct, there are separate service.bat files.  I continued digging after my post and came to this same conclusion.  I found that the delay can be added within the cmdStart of the service.bat.  After uninstalling and reinstalling my services this works to add a delay:

             

            REM create custom delay variable
            set customDelay=15
            
            :cmdStart
            REM Executed on service start
            del %RLOCK% 2>&1 | findstr /C:"being used" > nul
            if not errorlevel 1 (
              echo Could not continue. Locking file already in use.
              goto cmdEnd
            )
            echo Y > %RLOCK%
            TIMEOUT /T %customDelay%
            jbosssvc.exe -p 1 "Starting %SVCDISP%" > %RUNLG%
            call run.bat %JBOSSSTR% < %RLOCK% >> %RUNLG% 2>&1
            jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> %RUNLG%
            del %RLOCK%
            goto cmdEnd
            
            • 3. Re: Delay JBoss Services when running in Cluster
              nmitchell Newbie

              Also, FYI, yes my system is setup correctly so that each node is completely independent.  Each application has its own logs, and deploy configuration etc.