Bug 1465812 - [GSS](6.4.z) standalone.bat restart EAP unexpectedly
Summary: [GSS](6.4.z) standalone.bat restart EAP unexpectedly
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Scripts and Commands
Version: 6.3.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Radovan STANCEL
QA Contact: Pavel Slavicek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-28 09:28 UTC by Hiroki Daicho
Modified: 2020-08-13 09:29 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-08-19 12:47:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBEAP-12263 0 Major Verified standalone.bat restart EAP unexpectedly 2018-10-23 16:37:31 UTC
Red Hat Issue Tracker JBEAP-12423 0 Major Pull Request Sent [7.0.z] standalone.bat restart EAP unexpectedly 2018-10-23 16:37:31 UTC
Red Hat Issue Tracker WFCORE-3086 0 Major Resolved standalone.bat restart EAP unexpectedly 2018-10-23 16:37:31 UTC
Red Hat Knowledge Base (Solution) 3099441 0 None None None 2017-07-07 04:56:07 UTC

Description Hiroki Daicho 2017-06-28 09:28:12 UTC
Description of problem:

By the following code in standalone.bat, domain.bat, EAP restarts unexpectedly when the ERRORLEVEL set more than 10.
> if ERRORLEVEL 10 goto RESTART

For example, when Shutting down Windows while EAP is running, exit code is set as 143 and EAP is restarted.
Originally, EAP expect 10 for restarting.
The value is defined as the following constant.
org.jboss.as.process.ExitCodes.RESTART_PROCESS_FROM_STARTUP_SCRIPT

Version-Release number of selected component (if applicable):
6.x, 7.x

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Hiroki Daicho 2017-06-29 08:23:08 UTC
After the java process shutting down, exit code is put into ERRORLEVEL.
According to the following code, if the ERRORLEVEL is set more than 10, 
the "IF statement" will be true.

If EAP is runnning on Windows shutting down, the java process is finished with return code 143.

- standalone.bat

:RESTART
if x%XLOGGC% == x (
  "%JAVA%" %JAVA_OPTS% ^
   "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
   "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
      -jar "%JBOSS_HOME%\jboss-modules.jar" ^
      %MODULE_OPTS% ^
      -mp "%JBOSS_MODULEPATH%" ^
      -jaxpmodule "javax.xml.jaxp-provider" ^
       org.jboss.as.standalone ^
      "-Djboss.home.dir=%JBOSS_HOME%" ^
       %SERVER_OPTS%
) else (
  "%JAVA%" -Xloggc:%XLOGGC% %JAVA_OPTS% ^
   "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
   "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
      -jar "%JBOSS_HOME%\jboss-modules.jar" ^
      %MODULE_OPTS% ^
      -mp "%JBOSS_MODULEPATH%" ^
      -jaxpmodule "javax.xml.jaxp-provider" ^
       org.jboss.as.standalone ^
      "-Djboss.home.dir=%JBOSS_HOME%" ^
       %SERVER_OPTS%
)

if ERRORLEVEL 10 goto RESTART

Comment 2 Hiroki Daicho 2017-06-30 01:35:18 UTC
According to following example, "IF statement" of windows batch doesn't mean "EQUAL" validation.
It runs as "ERRORLEVEL >= 0".

- example_if_statement.bat
@echo off
# failed to call wrong api. ERRORLEVEL will be set to 1.
call :aa
echo %ERRORLEVEL% 
if ERRORLEVEL 0 echo TRUE

- result
> 1
> TRUE

Comment 3 Hiroki Daicho 2017-06-30 06:47:53 UTC
- Reported case
 - When the OS shutting down during EAP is still running. (exit code 143)
 - Shutting down with Ctrl+C and answering No for question of "Terminate batch job <Y/N>?". (exit code 130)

- Workaround
change the IF statament in standalone.bat/domain.bat as follows.

if %ERRORLEVEL%==10 goto RESTART
or
if %ERRORLEVEL% EQU 10 goto RESTART


Note You need to log in before you can comment on or make changes to this bug.