Skip to content

Instantly share code, notes, and snippets.

@jayankandathil
Last active February 9, 2017 02:06
Show Gist options
  • Save jayankandathil/6043139 to your computer and use it in GitHub Desktop.
Save jayankandathil/6043139 to your computer and use it in GitHub Desktop.
Production-quality start script for CQ 5.6.1 (Adobe Experience Manager) with JVM heap and garbage collection tuning - assumes the use of a 1.7 Oracle "HotSpot" JDK
#!/bin/bash
#
# 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.,
#
# % CQ_PORT=1234 ./start
#
# TCP port used for stop and status scripts
CQ_PORT=4502
# hostname of the interface that this server should listen to
#if [ -z "$CQ_HOST" ]; then
# CQ_HOST=
#fi
# runmode(s)
CQ_RUNMODE='author'
# name of the jarfile
CQ_JARFILE='app/cq-quickstart-5.6.1-standalone.jar'
# config for jaas
CQ_JAAS_CONFIG='etc/jaas.config'
# default JVM options
CQ_JVM_OPTS="-server"
CQ_JVM_OPTS="-Djava.awt.headless=true ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-XX:NewRatio=1 ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=4 ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-Xms8192m -Xmx8192m -XX:PermSize=256m -XX:MaxPermSize=1024m ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-Djava.io.tmpdir=/tmp ${CQ_JVM_OPTS}"
CQ_JVM_OPTS="-Djackrabbit.maxQueuedEvents=1000000 ${CQ_JVM_OPTS}"
# file size limit (ulimit)
if [ -z "$CQ_FILE_SIZE_LIMIT" ]; then
CQ_FILE_SIZE_LIMIT=8192
fi
# ------------------------------------------------------------------------------
# do not configure below this point
# ------------------------------------------------------------------------------
if [ $CQ_FILE_SIZE_LIMIT ]; then
CURRENT_ULIMIT=`ulimit`
if [ $CURRENT_ULIMIT != "unlimited" ]; then
if [ $CURRENT_ULIMIT -lt $CQ_FILE_SIZE_LIMIT ]; then
echo "ulimit ${CURRENT_ULIMIT} is too small (must be at least ${CQ_FILE_SIZE_LIMIT})"
exit 1
fi
fi
fi
BIN_PATH=$(dirname $0)
cd $BIN_PATH/..
if [ -z $CQ_JARFILE ]; then
CQ_JARFILE=`ls app/*.jar | head -1`
fi
CURR_DIR=$(basename $(pwd))
cd ..
START_OPTS="start -c ${CURR_DIR} -i launchpad"
if [ $CQ_PORT ]; then
START_OPTS="${START_OPTS} -p ${CQ_PORT}"
fi
if [ $CQ_RUNMODE ]; then
CQ_JVM_OPTS="${CQ_JVM_OPTS} -Dsling.run.modes=${CQ_RUNMODE}"
fi
if [ $CQ_HOST ]; then
CQ_JVM_OPTS="${CQ_JVM_OPTS} -Dorg.apache.felix.http.host=${CQ_HOST}"
START_OPTS="${START_OPTS} -a ${CQ_HOST}"
fi
if [ $CQ_USE_JAAS ]; then
CQ_JVM_OPTS="${CQ_JVM_OPTS} -Djava.security.auth.login.config=${CQ_JAAS_CONFIG}"
fi
java $CQ_JVM_OPTS -jar $CURR_DIR/$CQ_JARFILE $START_OPTS &
echo $! > $CURR_DIR/conf/cq.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment