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)

Adobe CQ – Toggle Preview


Adobe-CQ-264x300The coolest little tip/trick I’ve used in CQ in a while is the Toggle Preview trick that I came across a while ago.  This is not mine and I can’t for the life of me find where I picked it up from, so I apologize for not giving credit where credit is due.  I will update this when I find it.

Back to our program:  The Toggle Preview – When you are on your author instance, making many fine content edits, you might say to yourself, “Self?  I wish I could really see what this page looks like without having to deploy this page to dev/stage/whatever just to see if the CSS it rendering correctly.”  Yes, this is the lament of many CQ developers/designers.  Until today.

With this spectacular offer, you will get a a bookmark that will allow you to toggle the WCM mode  (enables/disabled).  What you get when the WCM mode is enables is nothing.  No sidekick and no left-nav DAM interface.  Just your page.  Here’s how it works…

  1. Create a new bookmark in your browser(s) of choice.  Give any name you like (I chose ‘Toggle Preview’ because I l like to live on the edge).
  2. Paste the code below into path.
  3. Navigate to your CQ Author instance and fire up your Experience Manager and find a page
  4. Take notice that your Sidekick and left-nav DAM interface are visible.
  5. Click on your new Toggle Preview shortcut
  6. Astonish your coworkers with your new sorcerous powers

Here’s the code.  Grab everything between the “===”:
=========================================

javascript:(function(){var a=”wcmmode=disabled”;var b=”/cf”;var c=function(a,b,c){var d=a;if(b.length!=0&&!(b.length==1&&b[0]==””)){d+=”?”+b.join(“&”)}d+=c;return d};var d=””;var e=[];if(window.location.search.substring(1)!=””){e=window.location.search.substring(1).split(“&”)}var f=””;if(window.location.pathname!=b){f=b+”#”+window.location.pathname;if(e.indexOf(a)!=-1){e.pop(a)}d=window.location.hash}else{f=window.frames[1].location.pathname;if(window.frames[1].location.search.substring(1)!=””){e=window.frames[1].location.search.substring(1).split(“&”)}if(e.indexOf(a)==-1){e.push(a)}d=window.frames[1].location.hash}var g=c(f,e,d);window.location=g})();

=========================================

Unfortunately, like other cool things, this will not work in CQ5.4 or Internet Explorer.

Please let me know if you have any issues with this.  I’ll be happy to help, if I can.

Adobe CQ – Auto Formatting in CRXDE Lite


Adobe-CQ-264x300A nice, little touch to make the world a better place…

This morning, I happened upon a post from Darren on the LiveCycle Development Kit Blog.  He describes a quick technique to format the code in CRXDE Lite by simply highlighting a block of code and clicking SHIFT+CTRL.  Imaging my surprise when it actually worked!!! He mentions that it works in Chrome, Firefox and IE but I have yet to test that.  My initial test was on CRX v2.4.22

However, I did test it with the CRX v2.2.0.68 and it does not work.  ;(

Most of us where I work have stopped using CRXDE Lite for the primary development IDE for out web apps since we worked out the integration with Eclipse.  However, I still find myself back in CRXDE Lite from time to time and this is a nice way for me to keep it tidy.

Thanks Darren!

Adobe CQ-Where The OSGi Configurations Live


Adobe-CQ-264x300Have you ever laid awake, staring at the ceiling, wondering where OSGi stores it configurations?  It’s the question that has plagued mankind for centuries.  Well, Jayen over at CQ-OPS has published a quick write-up on where these configurations live and you should give it a read.  However, I will quickly sum up:

Take for instance the Adobe CQ Launches Event Handler (picked at random).  If you go to the console and edit this bundle, you will see at the bottom the PID assigned is the namespace: “com.adobe.cq.wcm.launches.impl.LaunchesEventHandler”. The path to the config file on the file system generally follows this format with a prefix of “…/crx-quickstart/launchpad/config“.  So, for our example above, the path would be:
…/crx-quickstart/launchpad/config/com/adobe/cq/wcm/launches/impl/LaunchesEventHandler.config“.

Now you can sleep better tonight knowing that one of mankind’s greatest mysteries has been solved.