May 2, 2020
Estimated Post Reading Time ~

Production ready WINDOWS AEM startup script

@echo off
:: This script configures the start information for this server.
::
:: The following variables may be used to override the defaults.
:: For one-time overrides the variable can be set as part of the command-line; e.g.,
::
:: SET CQ_PORT=1234 & ./start.bat
::
setlocal
::* TCP port used for stop and status scripts
set CQ_PORT=4502
::* hostname of the interface that this server should listen to
:: if not defined CQ_HOST set CQ_HOST=
::* runmode(s)
set CQ_RUNMODE=author
::* name of the jarfile
:: if not defined CQ_JARFILE set CQ_JARFILE=
::* use jaas.config
:: if not defined CQ_USE_JAAS set CQ_USE_JAAS=true
::* config for jaas
set CQ_JAAS_CONFIG=etc\jaas.config
::* -------------------
::* Default JVM options
::* -------------------
set CQ_JVM_OPTS=-server
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.awt.headless=true
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:NewRatio=1
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+UseParallelGC
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+UseParallelOldGC
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:ParallelGCThreads=4
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Xms8192m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Xmx8192m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:PermSize=256m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:MaxPermSize=1024m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.io.tmpdir=C:\JAVA_TEMP
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+HeapDumpOnOutOfMemoryError
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:HeapDumpPath=C:\TEMP
::* ----------
::* CQ options
::* ----------
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djackrabbit.maxQueuedEvents=1000000
::* ------------------------------------------------------------------------------
::* do not configure below this point
::* ------------------------------------------------------------------------------
chdir /D %~dp0
cd ..
del conf\controlport
if not defined CQ_JARFILE for %%X in (app\*.jar) do set CQ_JARFILE=%%X
for %%* in (.) do set CurrDirName=%%~n*
cd ..
set START_OPTS=start -c %CurrDirName% -i launchpad
if defined CQ_PORT set START_OPTS=%START_OPTS% -p %CQ_PORT%
if defined CQ_RUNMODE set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dsling.run.modes=%CQ_RUNMODE%
if defined CQ_HOST set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dorg.apache.felix.http.host=%CQ_HOST%
if defined CQ_HOST set START_OPTS=%START_OPTS% -a %CQ_HOST%
if defined CQ_USE_JAAS set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.security.auth.login.config=%CQ_JAAS_CONFIG%
tasklist > oldTaskList.txt
start "CQ" cmd.exe /K java %CQ_JVM_OPTS% -jar %CurrDirName%\%CQ_JARFILE% %START_OPTS%
tasklist > newTaskList.txt
java -cp %~dp0 GetProcessID oldTaskList.txt newTaskList.txt java.exe > %CurrDirName%\conf\cq.pid
del newTaskList.txt
del oldTaskList.txt

My only comment is that I usually give it even more RAM if available and I add extra runmodes. E.g. set CQ_RUNMODE=author,prod

This is because custom runmodes make it very easy to target configurations to different environments using repository configuration of OSGI.

In case that ever goes down, here’s a copy:

@echo off
:: This script configures the start information for this server.
::
:: The following variables may be used to override the defaults.
:: For one-time overrides the variable can be set as part of the command-line; e.g.,
::
:: SET CQ_PORT=1234 & ./start.bat
::
setlocal

::* TCP port used for stop and status scripts
set CQ_PORT=4502

::* hostname of the interface that this server should listen to
:: if not defined CQ_HOST set CQ_HOST=

::* runmode(s)
set CQ_RUNMODE=author

::* name of the jarfile
:: if not defined CQ_JARFILE set CQ_JARFILE=

::* use jaas.config
:: if not defined CQ_USE_JAAS set CQ_USE_JAAS=true

::* config for jaas
set CQ_JAAS_CONFIG=etc\jaas.config

::* — — — — — — — — — -
::* Default JVM options
::* — — — — — — — — — -
set CQ_JVM_OPTS=-server
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.awt.headless=true
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:NewRatio=1
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+UseParallelGC
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+UseParallelOldGC
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:ParallelGCThreads=4
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Xms8192m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Xmx8192m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:PermSize=256m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:MaxPermSize=1024m
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.io.tmpdir=C:\JAVA_TEMP
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:+HeapDumpOnOutOfMemoryError
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -XX:HeapDumpPath=C:\TEMP

::* — — — — —
::* CQ options
::* — — — — —
set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djackrabbit.maxQueuedEvents=1000000

::* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
::* do not configure below this point
::* — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

chdir /D %~dp0
cd ..
del conf\controlport
if not defined CQ_JARFILE for %%X in (app\*.jar) do set CQ_JARFILE=%%X
for %%* in (.) do set CurrDirName=%%~n*
cd ..

set START_OPTS=start -c %CurrDirName% -i launchpad
if defined CQ_PORT set START_OPTS=%START_OPTS% -p %CQ_PORT%
if defined CQ_RUNMODE set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dsling.run.modes=%CQ_RUNMODE%
if defined CQ_HOST set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Dorg.apache.felix.http.host=%CQ_HOST%
if defined CQ_HOST set START_OPTS=%START_OPTS% -a %CQ_HOST%
if defined CQ_USE_JAAS set CQ_JVM_OPTS=%CQ_JVM_OPTS% -Djava.security.auth.login.config=%CQ_JAAS_CONFIG%

tasklist > oldTaskList.txt
start “CQ” cmd.exe /K java %CQ_JVM_OPTS% -jar %CurrDirName%\%CQ_JARFILE% %START_OPTS%
tasklist > newTaskList.txt
java -cp %~dp0 GetProcessID oldTaskList.txt newTaskList.txt java.exe > %CurrDirName%\conf\cq.pid
del newTaskList.txt
del oldTaskList.txt



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.