Bug 1041417 - Standalone.bat improvements
Summary: Standalone.bat improvements
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Scripts and Commands
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: DR12
: EAP 6.4.0
Assignee: jboss-set
QA Contact: Petr Kremensky
URL: https://c.na7.visual.force.com/apex/C...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-12 16:03 UTC by Shaun Appleton
Modified: 2019-08-19 12:45 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
suggested new standalone.bat (6.10 KB, text/plain)
2013-12-12 16:50 UTC, Shaun Appleton
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1091198 0 urgent CLOSED Domain directory properties only work on specific operating systems 2021-02-22 00:41:40 UTC

Internal Links: 1091198

Description Shaun Appleton 2013-12-12 16:03:14 UTC
Description of problem: Standalone.bat performs poorly when anti-virus software is running and there are many -D parameters set

Here is my times with anti-virus:
 START SCRIPT TIME  : 15:56:49.08
 DIRLOOP START TIME : 15:56:50.09 (+1s 01)
 DIRLOOP END TIME   : 15:57:21.88 (+31s 79)

 Jboss start time in 1 665 ms 

Times without AV (on a differnt machine - this explain JBoss start-up time difference):
 START SCRIPT TIME  : 16:21:47.51
 DIRLOOP START TIME : 16:21:47.87 (+0s 36)
 DIRLOOP END TIME   : 16:21:49.31 (+1s 44)

 Jboss start time in 11 219 ms

How to reproduce:

Run standalone.bat with many parameters - for example 
by adding the following to the standalone.conf.bat file

set JAVA_OPTS=%JAVA_OPTS% -Dkey01=value01 -Dkey02=value02 -Dkey03=value03 -Dkey04=value04 -Dkey05=value05 -Dkey06=value06 -Dkey07=value07 -Dkey08=value08 -Dkey09=value09 -Dkey10=value10
set JAVA_OPTS=%JAVA_OPTS% -Dkey11=value11 -Dkey12=value12 -Dkey13=value13 -Dkey14=value14 -Dkey15=value15 -Dkey16=value16 -Dkey17=value17 -Dkey18=value18 -Dkey19=value19 -Dkey20=value20
set JAVA_OPTS=%JAVA_OPTS% -Dkey21=value21 -Dkey22=value22 -Dkey23=value23 -Dkey24=value24 -Dkey25=value25 -Dkey26=value26 -Dkey27=value27 -Dkey28=value28 -Dkey29=value29 -Dkey30=value30

Running on a machine with no anti-virus standalone.bat takes ~ 1s to process
Running on a machine with ant-virus software on it it can take about 30 s to process the script.

Analysis has shown that the problem is due to the following loop (and specifically echo with findstr) creating many temporary files. These temp files then get scanned by the virus checker thus slowing down execution.

rem Setup JBoss specific properties

rem Setup directories, note directories with spaces do not work
set "CONSOLIDATED_OPTS=%JAVA_OPTS% %SERVER_OPTS%"
:DIRLOOP
echo(%CONSOLIDATED_OPTS% | findstr /r /c:"^-Djboss.server.base.dir" > nul && (
  for /f "tokens=1,2* delims==" %%a IN ("%CONSOLIDATED_OPTS%") DO (
    for /f %%i IN ("%%b") DO set "JBOSS_BASE_DIR=%%~fi"
  )
)
echo(%CONSOLIDATED_OPTS% | findstr /r /c:"^-Djboss.server.config.dir" > nul && (
  for /f "tokens=1,2* delims==" %%a IN ("%CONSOLIDATED_OPTS%") DO (
    for /f %%i IN ("%%b") DO set "JBOSS_CONFIG_DIR=%%~fi"
  )
)
echo(%CONSOLIDATED_OPTS% | findstr /r /c:"^-Djboss.server.log.dir" > nul && (
  for /f "tokens=1,2* delims==" %%a IN ("%CONSOLIDATED_OPTS%") DO (
    for /f %%i IN ("%%b") DO set "JBOSS_LOG_DIR=%%~fi"
  )
)

for /f "tokens=1* delims= " %%i IN ("%CONSOLIDATED_OPTS%") DO (
  if %%i == "" (
    goto ENDDIRLOOP
  ) else (
    set CONSOLIDATED_OPTS=%%j
    GOTO DIRLOOP
  )
)

:ENDDIRLOOP



It is recommended this loop be re-rewritten so temp files aren't created as running withou anti-virus is not a good idea.

Comment 1 Shaun Appleton 2013-12-12 16:50:44 UTC
Created attachment 835905 [details]
suggested new standalone.bat

Comment 2 Shaun Appleton 2013-12-12 17:26:59 UTC
domain.bat will also need modifying

Comment 3 Shaun Appleton 2013-12-13 10:39:13 UTC
The attached standalone.bat also includes

Variabilisation of the java command.

This makes the script more configurable.
There is a variable "JVM_NAME" (with value java by default):
if "%JVM_NAME%"=="" set JVM_NAME=java.exe
and then use this variable when you set the JAVA command
set  JAVA=%JVM_NAME%
set "JAVA=%JAVA_HOME%\bin\%JVM_NAME%"

Comment 12 Kabir Khan 2014-11-20 12:38:27 UTC
PR 1911 was closed

Comment 14 Petr Kremensky 2014-12-08 10:42:25 UTC
Verified on EAP 6.4.0.DR12, batch scripts no longer turns the arguments into files.

PR brings regressions in domain.bat which will be covered as part of BZ1091198.


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