13 Replies Latest reply on Apr 17, 2014 9:31 PM by wheresjbob

    Shutdown of JBoss AS 7

    igusev

      Hello!

       

      Is there a possibility to shutdown the JBoss AS 7 from a command line?

      For instance, specify some arguments to standalone.bat/sh or domain.bat/sh?

       

      Thanks in advance

        • 1. Shutdown of JBoss AS 7
          jaikiran

          I just added a "Stopping a running instance of standalone server" section to the JBoss AS7 user guide http://community.jboss.org/wiki/JBossAS7UserGuide. Give it a try.

          • 2. Re: Shutdown of JBoss AS 7
            rrthomas67

            The "Stopping a running instance of standalone server" section of the JBoss AS7 user guide seems to be out of date for 7.1. 

             

            Apparently, someone requested that the jboss-admin.sh script be renamed jboss-cli.sh (or .bat on Windows). 

            See: https://issues.jboss.org/browse/AS7-2310

             

            So, just to prevent the next person from having to chase the same rabbit, the command to shut down JBoss AS 7.1, running as a daemon / service is:

             

            {JBOSS_HOME}/bin/jboss-cli.sh --connect command=:shutdown

            • 3. Re: Shutdown of JBoss AS 7
              johanvermeij

              I am confused by the shutdown command because shutdown is not in the command list (I see undeploy but that does not effectuate a shutdown of the instance).

               

              I also always get an error saying that it is not possible to connect to localhost:9999

              I tried to use the real IP address in the standalone-full.xml but that has no effect.

              After this error I am inside the shell as "not connected" but when I type "connect" I am connected.

               

              I am running automatic robotised tests and one important part of the test is to shutdown a standalone instance and to start a new one.

              That happens in the middle of the night.

               

              The effect is the same using CentOS Linux and Windows XP

              • 4. Re: Shutdown of JBoss AS 7
                wdfink

                It will be not a direct command of the cli, it is a statement for the server (notice the ':' ) :shutdown

                If you type a ':' in the cli and then use the tab completion it will be displayed.

                 

                Maybe your command is wrong or interpreted by the shell.

                For me

                bin/jboss-cli.sh --connect --command=:shutdown

                bin/jboss-cli.sh --connect command=:shutdown

                bin/jboss-cli.sh --connect :shutdown

                work

                • 5. Re: Shutdown of JBoss AS 7
                  johanvermeij

                  I tried all 3 commands from the command line both on a CentOS Linux server and on WIndows XP

                   

                  The example below is from Linux (I am obviously doing something stupid but I don't know what it is)

                   

                  This is the result:

                  [jboss@localhost bin]$ ./jboss-cli.sh --connect --command=:shutdown

                  The controller is not available at localhost:9999

                  You are disconnected at the moment. Type 'connect' to connect to the server or '                                                                             help' for the list of supported commands.

                  [jboss@localhost bin]$ ./jboss-cli.sh --connect command=:shutdown

                  The controller is not available at localhost:9999

                  You are disconnected at the moment. Type 'connect' to connect to the server or '                                                                             help' for the list of supported commands.

                  [jboss@localhost bin]$ ./jboss-cli.sh --connect :shutdown

                  The controller is not available at localhost:9999

                  You are disconnected at the moment. Type 'connect' to connect to the server or '                                                                             help' for the list of supported commands.

                  • 6. Re: Shutdown of JBoss AS 7
                    wdfink

                    What version of AS7 do you use? Which mode and how you configured the interfaces and ports?

                    • 7. Re: Shutdown of JBoss AS 7
                      johanvermeij

                      I use jboss-as-7.1.0.Final

                       

                      I run in standalone mode

                       

                      I will attach standalone-full.xml

                      • 8. Re: Shutdown of JBoss AS 7
                        emuckenhuber

                        You would need to connect to the correct address adding something like: "--controller=192.168.2.2:9999" to the cmd argument.

                        • 9. Re: Shutdown of JBoss AS 7
                          johanvermeij

                          Thank you und vielen dank auch

                           

                          The --controller bit did the trick

                          • 10. Re: Shutdown of JBoss AS 7
                            mciancaz

                            Gracias, me faltaba especificar el controller

                            • 11. Re: Shutdown of JBoss AS 7
                              saodesign

                              I updated my services.bat to the following.  This is for JBOSS 7.1.1, using the standalone.bat and jboss-cli to start, restart and shutdown the service.

                               

                              This is very similar to previous posts, however other posts were relaying on 'run.bat' which appears to be deprecated.  It also relied on a shutdown.bat that no longer existed in the bin folder.

                               

                              =================================================================

                              @echo off

                              REM JBoss, the OpenSource webOS

                              REM

                              REM Distributable under LGPL license.

                              REM See terms of license at gnu.org.

                              REM

                              REM -------------------------------------------------------------------------

                              REM JBoss Service Script for Windows

                              REM -------------------------------------------------------------------------

                               

                               

                               

                               

                              @if not "%ECHO%" == "" echo %ECHO%

                              @if "%OS%" == "Windows_NT" setlocal

                              set DIRNAME=%CD%

                               

                               

                              REM

                              REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated

                              REM during the build with ant filter.

                              REM

                              set SVCNAME=JBAS50SVC

                              set SVCDISP=JBoss Application Server 5.0

                              set SVCDESC=JBoss Application Server 5.0.0 GA/Platform: Windows x64

                              set NOPAUSE=Y

                               

                               

                              REM Suppress killing service on logoff event

                              set JAVA_OPTS=-Xrs

                               

                               

                              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.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service.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.log

                              call standalone.bat < .r.lock >> run.log 2>&1

                              jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.log

                              del .r.lock

                              goto cmdEnd

                               

                               

                              :cmdStop

                              REM Executed on service stop

                              echo Y > .s.lock

                              jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > shutdown.log

                              jboss-cli --connect command=:shutdown

                              k <

                              jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> shutdown.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.log

                              jboss-cli --connect command=:shutdown

                              k <

                              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.log

                              call standalone.bat < .r.lock >> run.log 2>&1

                              jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.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

                               

                              ===================================================================

                              • 12. Re: Shutdown of JBoss AS 7
                                mhavrda

                                Thank you very much.

                                • 13. Re: Shutdown of JBoss AS 7
                                  wheresjbob

                                  Thanks.  worked for me.