Adobe CQ: Startup Scripts for Author and Publisher


Adobe-CQ-264x300Recently, I stood up a CQ5.6 stack on a local machine running CentOS 6 for testing some things and one of tasks I have been wanting to do is automate the startup scripts for the author and publisher instances.  In the past, we did not have much luck but never really invested the time to work it out, so I took this rare opportunity to tackle the problem.

First, as with most things, was to search Google.  As luck would have it, I found several posts on the subject but not of the scripts worked out of the gate, so I tweaked them to fit my needs and now everything is working well.  First, here is my author script… it is the same as my publisher script except for the obvious ‘author/publisher’ folder in the path:

#!/bin/bash
#
# /etc/r.d/init.d/cqauthor
#
# Description: This service manages the 
# Adobe WEM Content Management java process.
# Source function library.
. /etc/rc.d/init.d/functions
CQ5_ROOT=/opt/adobe_cq/author
CQ5_USER=root
########
SERVER=${CQ5_ROOT}/crx-quickstart
START=${SERVER}/bin/start
STOP=${SERVER}/bin/stop
STATUS="${SERVER}/bin/status"
case "$1" in
start)
echo -n "Starting cq5 services: "
su - ${CQ5_USER} ${START}
touch /var/lock/subsys/cq5
;;
stop)
echo -n "Shutting down cq5 services: "
su - ${CQ5_USER} ${STOP}
rm -f /var/lock/subsys/cq5
;;
status)
su - ${CQ5_USER} ${STATUS}
;;
restart)
su - ${CQ5_USER} ${STOP}
sleep 5s # gives the system time to shutdown
su - ${CQ5_USER} ${START}
;;
*)
echo "Usage: cq5 {start|stop|status|restart}"
exit 1
;;
esac

For these scripts, I removed the ‘reload function’ and created a ‘restart’ function.  Just sounds better.  Also, I added the ‘sleep 5s’ between the stop and start in the restart function because some systems take a little bit of time to kill off the processes.  I have yet to test this on a production system with a huge JCR which may require that I add a couple more seconds.

Next I saved a version for the author and publisher in the /etc/rc.d/init.d/ folder and named them ‘cqauthor’ and ‘cqpublisher.’  I thought about having one script that accepts an argument for server type but most likely, this scripts will be on a server with only one instance of CQ running so it really wasn’t a compelling exercise other than to just do it.

Finally, I added them to the chkconfig so they would fire when the server started:

chkconfig on cqauthor

Also, The ‘start’ and ‘status’ scripts in the crx-quickstart/bin folder were not able to find java.  This is probably due to my not setting the java path globally.  To quickly fix the issue, I added the following to these two scripts:

JAVA_HOME=/opt/java/bin

$JAVA_HOME/java… (prefix wherever java appears).

This fixed the problem for the time being.  As I mentioned in past posts, I NEED to control which JDK is running on my machines so, java is passively available to the system via the path.  This is not an optimal production server config but it works rather well for my local workstations where I am the only user.

 

EDIT:  Giving credit where credit is due.  This blog is where I started my script work: http://cqdump.wordpress.com/2011/11/15/cq5-init-script/

Here’s another that I used as well: http://www.wemblog.com/2011/11/how-to-write-cq-wem-init-script-for.html (scroll to the bottom… the second script was designed for cq5.5)

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s