Tuesday, September 8, 2009

Creating a service in AIX

Wanted to control dmgr with startsrc and stopsrc commands

First create a subsystem using mkssys

#!/bin/ksh
#-R \
mkssys -s dmgr -G was61 -p "/usr/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/dmgrService.sh" -u $(id -u) -S -n 15 -f 9 -Q


#!/bin/ksh
trap "" HUP INT QUIT TSTP STOP
trap "stopService" TERM
stopService ()
{
#cleanup stuff

echo " Cleaning now `date` " >>/tmp/test1.log

#/usr/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/stopManager.sh -username <>
ath.Varanasi -password <>
exit 0

}

#launchScript=/usr/IBM/WebSphere/AppServer/profiles/Dmgr01/bin
numRetries=3

#binDir=`dirname $0`
# Set the ulimit
LIMIT=`ulimit -n`
if [ "${LIMIT}" != "unlimited" ]
then
if [ $LIMIT -lt 1024 ]
then
ulimit -n 1024
fi
fi

RETRY=0
while [ $RETRY -lt $numRetries ]
do
echo launching server using start_dmgr.sh >>/tmp/test1.log
#/usr/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/start_dmgr.sh
echo pid of dmgr is $$ >>/tmp/test1.log
#/bin/ksh exec sleep 3600
/usr/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/sleep.sh

while true
do
ps -aef | grep sleep | grep -v grep
if [ $? -eq 0 ]
then
sleep 1
fi
done
# $binDir/$launchScript
rc=$?
echo exit code: $rc

# Increment retry count on anything other than a normal exit code
if [ $rc -gt 0 ]
then
RETRY=`expr $RETRY + 1`
fi

case $rc in
0) break ;;
esac
done

exit 0

No comments:

Post a Comment