Question : how to launch/stop Pax at any Linux startup/shutdown ?
Answer :
- launch Pax as an extra Linux service
- a daemon being available since Pax v0.20 (refer to OPS4J site for introduction)
Details :
Step #1 : consider these shell variables :
#!/bin/bash
#
# Common definitions & Current working directory
# . .start_profile
# <begin> of such a profile
cd /home/osgi
export PORTWEB=8080
export DIRBASICBUNDLES=./bundles
PATH_RUNNER=./pax/
PATH_PROV=./provisionning_file.txt
PAXD_PASSWD=./paxd_passwd
PATH_PAX_BIN=./pax/bin
PATH_PAX_DIR=~osgi/.pax/runner
PATH_PAX_LOCK=$PATH_PAX_DIR/org.ops4j.pax.runner.daemon.lock
# <end>
Step #2 : here is an example of paxd service, to be added under /etc/init.d :
# Provisionning file
# ------------------
if [ ! -f $PATH_PROV ] ; then
echo "Creating provisionning file..."
list=`ls $DIRBASICBUNDLES/*.jar`
for bundle in $list; do echo "file:$bundle" >> $PATH_PROV; done
for opt in $JAVA_OPTS; do echo $opt >> $PATH_PROV; done
echo "-Dorg.osgi.service.http.port=$PORTWEB" >> $PATH_PROV
echo "=> done"
else
echo "Provisionning file retrieved !"
fi
# Depending on input option
# -------------------------
case "$1" in
start)
rm -f $PATH_PAX_LOCK
if [ -d $PATH_RUNNER ] ; then
echo "Launching PAX Runner Daemon... "
if [ ! -d $PATH_PAX_DIR ] ; then
su osgi -c "$PAXD_PASSWD $PATH_PAX_BIN/pax-rund.sh --startd --profiles=war,obr,log,config,felix.event,felix.ds --usePersistedState=true $PATH_PROV"
else
su osgi -c "$PATH_PAX_BIN/pax-rund.sh --startd --profiles=war,obr,log,config,felix.event,felix.ds --usePersistedState=true $PATH_PROV"
fi
fi
;;
stop)
echo "Stopping PAX Runner Daemon... "
su osgi -c "$PATH_PAX_BIN/pax-rund.sh --stop"
rm -f $PATH_PAX_LOCK
sleep 1
;;
restart)
;;
*)
echo "Usage: $N {startstoprestart}" >&2
exit 1
;;
esac
exit 0
Step #3 : Finally, run the update-rc.d command to automatically add any required links to this new service, as per your /etc/initab.
Monday, 14 June 2010
Subscribe to:
Post Comments (Atom)





No comments:
Post a Comment