#/bin/bash
cid=0
httpcode=000
check_up(){
        echo "-----------------------------"
        echo "正在确认服务是否完成启动！"
        while  [ $httpcode != 200 ]
        do
                httpcode=`curl -I -m 10 -o /dev/null -s -w %{http_code}  http://localhost:8182/longvideoapi/test`
                echo  -en  ". "
                sleep 2
        done
        echo  " "
        echo   “请求返回值：  $httpcode  服务器启动完成”
        echo "-----------------------------"  

}



stop(){
        pid = `ps -ef|grep "MediaCenter"|grep -v  grep|awk  '{print $2}'`
        if [ $pid  ];then
            kill  -9  $pid
        else
            echo  "Server is not running"
        fi


}
start(){
      java -jar  MediaCenter.jar
}

  case "$1" in
   'start')
      start
      ;;
   'stop')
     stop
     ;;
   'restart')
     stop
     start
     ;;
   'status')
     check_up
     ;;
  *)
     echo "Usage: $0 {start|stop|restart|status}"
     exit 1
;;
esac
