Chuyển đến nội dung chính

How to startup scripts for Author and Publisher

Use case : You want to start and stop CQ on system start and stop

Solution: Here is script that you can use. Put this script in /etc/init.d


1. Create a file /etc/init.d/cq5 on your server and copy the contents from below script.
2. edit the file and make the following changes
update the "pidfile:" config to match your cq instance
update the "CQ5_ROOT" and "CQ5_USER" variables to match your cq instance
3. Run this command:
chmod 755 /etc/init.d/cq5
4. Run this command to add the config to redhat startup and shutdown:
chkconfig --add cq5

Recently, 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)

Nhận xét

Bài đăng phổ biến từ blog này

[PERFORMANCE] Adobe WEM/CQ performance tuning

Adobe WEM/CQ performance tuning Contents Caching-related configurations CRX Bundle cache CRX Search index handler (Lucene) cache Tar PM index cache Scalability Maintenance Optimizing Tar Files (for Tar Persistence Manager) Data Store Garbage Collection Main documentation you should consult first: http://dev.day.com/docs/en/cq/current/deploying/performance.html http://dev.day.com/content/kb/home/cq5/CQ5Troubleshooting/performancetuningtips.html Caching-related configurations CRX Bundle cache CRX caches bundles, consisting of a node with all its properties. This is used by all bundle-based Persistence Managers. The default size of BundleCache is 8 MB. If this is too small it can cause an excessive number of read-accesses to the underlying persistence layer. Set the bundleCacheSize to something larger than the default. See more here: http://dev.day.com/docs/en/cq/current/deploying/performance.html#CRX%20Bundle%20Cache CRX Search index handler (Lucene...

[Query Builder] Advanced Search

Using the Advanced Search When using a list, select from the 'Build list using' options 'Advanced Search.' This will open a new tab in the list window with one text box labeled: 'Querybuilder Predicate Notation.' This is asking for a few lines of code to define search parameters. Example Code - With Explanations of Results Searching for Pages type=cq:Page property=jcr:content/jcr:title property.value=Places 'type' defines what sort of object you'll be searching for (it's usually a page). 'property' defines what property of the object you'll be filtering by; in this case, its by the title. 'property.value' defines your search term. So this search would be searching all PAGES with the TITLE of PLACES. So it would find every page titled Places. *IMPORTANT* Searches by title ARE case-sensitive, so 'Places' is not the same as 'places'. type=cq:Page path=/cq/sandbox property=jcr:cont...

[CQ6-SYSTEM] MAINTAINING THE REPOSITORY - Reduce repository size (cleanup repository)

Compacting Tar Files As data is never overwritten in a tar file, the disk usage increases even when only updating existing data. To make up for the growing size of the repository, AEM employs a garbage collection mechanism called Tar Compaction. The mechanism will reclaim disk space by removing obsolete data from the repository. Revision Clean Up By default, tar file compaction is automatically run each night between 2 am and 5 am. The automatic compaction can be triggered manually in the Operations Dashboard via a maintenance job called Revision Clean Up. To start Revision Clean Up you need to: Go to the AEM Welcome Screen. In the main AEM window, go to Tools - Operations - Dashboard - Maintenance or directly browse to http://localhost:4502/libs/granite/operations/content/maintenance.html Click on Daily Maintenance Window. Hover over the Revision Clean Up window and press the Start button. The icon will turn orange to indicate that the Revision Clean Up ...