Today in France, we celebrate ""
Posts
04/07/10 : Android sorting
16/06/10 : Flex XML parsing
15/06/10 : Android settings
14/06/10 : Pax daemon
10/06/10 : Bundle CPU %
04/06/10 : Wicket CheckBox
03/06/10 : Thread monitor

By tag
Ajax
Android
AspectJ
Flex
Java
JMX
OSGi
Shell
Wickets

Here are some lights and tips on various Object Oriented Programming aspects that I would have dealt with during my software development and architecture activities..., for sharing.

"Beauty is an inexhaustible source of happyness for the one who discovers it" (Alexis Carrel)



Monday, 14 June 2010

Automatic Pax daemon commands

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.

No comments:

Post a Comment

Previous Post Next Post