1 Reply Latest reply on Aug 3, 2009 5:30 PM by peterj

    Cannot start multiple JBoss Windows services

      I'm trying to install multiple JBoss services on Windows (one for each main web application we have – 2 currently). I get 2 of them installed and I can start one, but the other starts, then stops. I'm installing them using tweaked service.bat So I would install the first service as JBOSSSVC1 using service_1.bat that looks like this:

      REM
      REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated
      REM during the build with ant filter.
      REM
      set SVCNAME=JBASCHSVC
      set SVCDISP=JBoss AS 1
      set SVCDESC=JBoss Application Server 5.1.0 GA/Platform: Windows x86
      set NOPAUSE=Y
      set JBOSSOPT=-c app1 -b 192.168.0.1
      set JBOSSSTOP=-n app1 -S 192.168.0.1

      REM Suppress killing service on logoff event
      set JAVA_OPTS=-Xrs -Djboss.service.binding.set=ports-default

      REM Figure out the running mode

      if /I "%1" == "install" goto cmdInstall
      if /I "%1" == "uninstall" goto cmdUninstall
      if /I "%1" == "start" goto cmdStart
      if /I "%1" == "stop" goto cmdStop
      if /I "%1" == "restart" goto cmdRestart
      if /I "%1" == "signal" goto cmdSignal
      echo Usage: service install^|uninstall^|start^|stop^|restart^|signal
      goto cmdEnd

      REM jbosssvc retun values
      REM ERR_RET_USAGE 1
      REM ERR_RET_VERSION 2
      REM ERR_RET_INSTALL 3
      REM ERR_RET_REMOVE 4
      REM ERR_RET_PARAMS 5
      REM ERR_RET_MODE 6

      :errExplain
      if errorlevel 1 echo Invalid command line parameters
      if errorlevel 2 echo Failed installing %SVCDISP%
      if errorlevel 4 echo Failed removing %SVCDISP%
      if errorlevel 6 echo Unknown service mode for %SVCDISP%
      goto cmdEnd

      :cmdInstall
      jbosssvc_ch.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service_1.bat
      if not errorlevel 0 goto errExplain
      echo Service %SVCDISP% installed
      goto cmdEnd

      :cmdUninstall
      jbosssvc.exe -u %SVCNAME%
      if not errorlevel 0 goto errExplain
      echo Service %SVCDISP% removed
      goto cmdEnd

      :cmdStart
      REM Executed on service start
      del .r.lock 2>&1 | findstr /C:"being used" > nul
      if not errorlevel 1 (
      echo Could not continue. Locking file already in use.
      goto cmdEnd
      )
      echo Y > .r.lock
      jbosssvc.exe -p 1 "Starting %SVCDISP%" > run_1.log
      call run.bat %JBOSSOPT% < .r.lock >> run_1.log 2>&1
      jbosssvc_ch.exe -p 1 "Shutdown %SVCDISP% service" >> run_1.log
      del .r.lock
      goto cmdEnd

      :cmdStop
      REM Executed on service stop
      echo Y > .s.lock
      jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > shutdown_1.log
      call shutdown %JBOSSSTOP% < .s.lock >> shutdown_1.log 2>&1
      jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> shutdown_1.log
      del .s.lock
      goto cmdEnd

      :cmdRestart
      REM Executed manually from command line
      REM Note: We can only stop and start
      echo Y > .s.lock
      jbosssvc.exe -p 1 "Shutting down %SVCDISP%" >> shutdown_1.log
      call shutdown %JBOSSSTOP% < .s.lock >> shutdown_1.log 2>&1
      del .s.lock
      :waitRun
      REM Delete lock file
      del .r.lock > nul 2>&1
      REM Wait one second if lock file exist
      jbosssvc.exe -s 1
      if exist ".r.lock" goto waitRun
      echo Y > .r.lock
      jbosssvc.exe -p 1 "Restarting %SVCDISP%" >> run_1.log
      call run.bat %JBOSSOPT% < .r.lock >> run_1.log 2>&1
      jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run_1.log
      del .r.lock
      goto cmdEnd

      :cmdSignal
      REM Send signal to the service.
      REM Requires jbosssch.dll to be loaded in JVM
      @if not ""%2"" == """" goto execSignal
      echo Missing signal parameter.
      echo Usage: service signal [0...9]
      goto cmdEnd
      :execSignal
      jbosssvc.exe -k%2 %SVCNAME%
      goto cmdEnd

      :cmdEnd

      I install the service and everything looks ok. If I try and install a second service (service2) for a different application (app2), it will not stay started. It will start then right away stop again. The event logs have no useful info. The run.log and shutdown.log files have nothing in them.

      app2 is configured to start with the ports-01 switch turned on and has it's own service_2.bat file.