Skip to content

Instantly share code, notes, and snippets.

@frieder
Last active June 30, 2022 10:55
Show Gist options
  • Save frieder/48f207638c77b76b77d7ff78e83f3391 to your computer and use it in GitHub Desktop.
Save frieder/48f207638c77b76b77d7ff78e83f3391 to your computer and use it in GitHub Desktop.
AEM 6.x systemd start script
The following start script has been tested with SLES 12 SP2, AEM 6.3 and Java 8u161.
-------------------------------------------------------------------------------------------------------------
cat << 'EOF' > /etc/systemd/system/aem.service
[Unit]
Description=Adobe Experience Manager
After=network.target
[Service]
Type=forking
ExecStart=/data/aem/instance/crx-quickstart/bin/start
ExecStop=/data/aem/instance/crx-quickstart/bin/stop
User=aem
WorkingDirectory=/data/aem/instance
PIDFile=/data/aem/instance/crx-quickstart/conf/cq.pid
LimitNOFILE=16000
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
EOF
--------------------------------------------
mkdir /etc/systemd/system/aem.service.d/
--------------------------------------------
cat << 'EOF' > /etc/systemd/system/aem.service.d/aem.conf
[Service]
Environment="CQ_PORT=4502"
Environment="CQ_RUNMODE=author,runmode1,runmode2,nosamplecontent"
Environment="CQ_JVM_OPTS=-server \
-Djava.awt.headless=true \
-Djava.io.tmpdir=/data/aem/tmp/ \
-Djavax.net.ssl.trustStore=/data/java/jdk8_171/jre/lib/security/cacerts \
-Djavax.net.ssl.trustStorePassword=changeit \
-Xmx12g \
-XX:MaxMetaspaceSize=1g \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/data/aem/dumps/ \
-XX:+PrintGCDateStamps -verbose:gc \
-XX:+PrintGCDetails \
-Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,address=45028,suspend=n \
-XX:+JavaMonitorsInStackTrace \
-Dcom.sun.management.jmxremote.port=45029 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=5 \
-XX:GCLogFileSize=20M \
-Xloggc:/data/aem/logs/gc.log"
EOF
@shahzore-qureshi
Copy link

You are a lifesaver. Thank you SO MUCH!!! I am crying in joy hahaha.

@frieder
Copy link
Author

frieder commented Aug 6, 2019

You're welcome, I'm glad it was of use to you. ;)

@svenux
Copy link

svenux commented Oct 1, 2019

Would't it be better to monitor the AEM pid via PIDFile=/path/to/aem/crx-quickstart/conf/cq.pid and also set Type=forking? In this case you also don't need the RemainAfterExit parameter anymore.

@frieder
Copy link
Author

frieder commented Oct 2, 2019

You are right with your suggestions. At work we already do it as you described but I didn't update the snippet here. Thx for pointing it out, I'll update this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment