#! /bin/sh
PATH=/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/root/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/lib/mit/bin:/usr/lib/mit/sbin

APP=miads

cd /data2/app/$APP

PROCESS=`pwd | xargs -i basename {}`

#for process number check and alert send
processnum=`/bin/ps -ef | grep "\./${PROCESS}" | grep -v grep  |/usr/bin/wc -l`
if [ $processnum -lt 1 ]
then
    echo "${PROCESS} processnum is $processnum less than 1, please check"
    cd /data2/app/${PROCESS}/tools/
    ./start.sh
else
    echo $processnum
fi

echo "Done."
