#!/bin/bash
echo "--------autoserver------->>"  
DIR="$( cd "$( dirname "$0"  )" && pwd  )"
cd $DIR
#export LC_ALL=zh_CN.UTF-8
export JAVA_HOME=/usr/lib/jvm/java
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH 
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
#export LC_ALL=zh_CN.UTF-8
#echo $DIR
NAME=`ls | grep .jar`
if [ "${NAME}x" = "x"  ];then
		echo "##########################"
		echo "#                        #"
		echo "#    jar not found !     #"
		echo "#                        #"
		echo "##########################"
else
		PORT=`ps -ef | grep ${NAME} | grep -v grep | awk '{print $2}'`
		if [ "${PORT}x" != "x"  ];then
			echo "##########################"
			echo "#                        #"
			echo "#   Service is running   #"
			echo "#                        #"
			echo "##########################"
		else
			 java -jar ${NAME}  verbose &
			#echo ${NAME}
		fi 
fi
#echo ok
echo `date '+%Y-%m-%d %H:%M:%S'`
#java 
cd -
