Question

How do I create a Linux init script to manage my AEM java process?

Answer

A sample Linux init script (tested in Redhat Linux) is provided below.

To use the init script:

1. Copy the script to a new file /etc/init.d/aem6 on your server.

2. Edit the file and make the following changes:​

  • Set AEM_ROOT variable to the directory path which contains the AEM jar file.
  • Set AEM_USER variable to the name of the system user that will start and stop AEM.
3. Run the command:​
chmod 755 /etc/init.d/aem6
 
4. Run this command to add the config to redhat startup and shutdown:
chkconfig --add aem6

Huomautus:

Prior to installing AEM as a Linux service:

1. AEM should have already been installed or unpacked from the installation jar file and your license.properties file should already be in place.  See the official documentation for more details.

2. Verify that the start and stop scripts installed with AEM are working as expected. The scripts are located under /crx-quickstart/bin.

  • Allocate enough heap space to the JVM by setting the -Xmx parameter in the CQ_JVM_OPTS variable.
  • Make sure the correct java binary is accessible via the Path of the AEM process user's shell (AEM_USER variable).

Sample Init Script

#!/bin/bash
#
# /etc/rc.d/init.d/aem6
#
#
# # of the file to the end of the tags section must begin with a #
# character. After the tags section, there should be a blank line.
# This keeps normal comments in the rest of the file from being
# mistaken for tags, should they happen to fit the pattern.>
#
# chkconfig: 35 85 15
# description: This service manages the Adobe Experience Manager java process.
# processname: aem6
# pidfile: ${AEM_ROOT}/crx-quickstart/conf/cq.pid

# Source function library.
. /etc/rc.d/init.d/functions

SCRIPT_NAME=`basename $0`
AEM_ROOT=/opt/aem6
AEM_USER=aem

########
BIN=${AEM_ROOT}/crx-quickstart/bin
START=${BIN}/start
STOP=${BIN}/stop
STATUS="${BIN}/status"

case "$1" in
start)
echo -n "Starting AEM services: "
su - ${AEM_USER} ${START}
touch /var/lock/subsys/$SCRIPT_NAME
;;
stop)
echo -n "Shutting down AEM services: "
su - ${AEM_USER} ${STOP}
rm -f /var/lock/subsys/$SCRIPT_NAME
;;
status)
su - ${AEM_USER} ${STATUS}
;;
restart)
su - ${AEM_USER} ${STOP}
su - ${AEM_USER} ${START}
;;
reload)
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|status|reload}"
exit 1
;;
esac

Lisensoitu Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License -lisenssin mukaan.  Creative Commons -lisenssien ehdot eivät koske Twitter™- ja Facebook-viestejä.

Lakisääteiset ilmoitukset   |   Online-tietosuojakäytäntö