#!/bin/sh
mainclasspath="com.zhan.message.MessageServer"
classpath="."
for jarpath in `ls lib/*.jar`
do
classpath=$classpath:$jarpath
done
# echo $classpath
echo $mainclasspath
pid=`ps -ef | grep ${mainclasspath} | grep -v grep |awk '{print $2}'`
if [ $pid ]; then
echo ${mainclasspath} is running pid=$pid
read -r -p "restart the server? [y/n] " input
case $input in
[yY][eE][sS]|[yY])
kill -9 $pid
echo restart ${mainclasspath}......
sleep 3
nohup java -server -XX:-UseGCOverheadLimit -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -classpath ".:lib/*" $mainclasspath >/dev/null 2>&1 &
tail -f logs/info.log
;;
[nN][oO]|[nN])
echo "No"
exit 1
;;
*)
echo "Invalid input..."
exit 1
;;
esac
else
nohup java -server -XX:-UseGCOverheadLimit -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -classpath ".:lib/*" $mainclasspath >/dev/null 2>&1 &
tail -f logs/info.log
fi