자바 데 몬 시작 및 스 크 립 트 닫 기

7404 단어 각본데 몬자바
#     
PROJECT_NAME=route

#    
APP_HOME=$(dirname $(pwd))/$PROJECT_NAME

#java   
JAVA_LIB_PATH=$APP_HOME/resource/daemon/lib

#JAVA_HOME
JAVA_HOME=/home/software/jdk1.8


#    ,route.jar   mf      jar ,         jar 
CLASS_PATH=$APP_HOME/resource/daemon/route.jar
#CLASS_PATH=$CLASS_PATH:$JAVA_LIB_PATH/netty-all-4.1.17.Final.jar
#CLASS_PATH=$CLASS_PATH:$JAVA_LIB_PATH/disruptor-3.2.1.jar
#CLASS_PATH=$CLASS_PATH:$JAVA_LIB_PATH/log4j-api-2.0.2.jar
#CLASS_PATH=$CLASS_PATH:$JAVA_LIB_PATH/log4j-core-2.0.2.jar


#  
JAVA_OPTS=-Xms512m -Xmx512m -Xnoclassgc -Xverify:none

#     
MAIN_CLASS=com.dice.game.StartupWrapper

#  ID  
PID_FILE=${APP_HOME}/${PROJECT_NAME}.pid


#      
LOG_FILE=${APP_HOME}/logs/${PROJECT_NAME}.out


#        ,        
if [ ! -f "$PID_FILE" ]; then  
  touch "$PID_FILE"  
    echo 0 > $PID_FILE
fi

if [ ! -f "$LOG_FILE" ]; then
  touch "$LOG_FILE"
fi 


#  
echo "service name: $PROJECT_NAME"
echo "app home: $APP_HOME"
echo "java home: $JAVA_HOME"
echo "class path: $CLASS_PATH"
echo "main class: $MAIN_CLASS"
echo "pid file : $PID_FILE"

pid=0

#  pid
getpid() {
   pid=`cat $PID_FILE`
}

#    
start() {
   getpid

   if [ $pid -ne 0 ]; then
      echo "================================"
      echo "warn:  already started! or bad close last time!"
      echo "================================"
   fi

    echo -n "Starting..."
    nohup $JAVA_HOME/bin/java -server $JAVA_OPTS -classpath $CLASS_PATH $MAIN_CLASS >> $LOG_FILE 2>&1 & echo $! > $PID_FILE
    getpid
    if [ $pid -ne 0 ]; then
     echo "================================="
         echo "[Start Success] (pid=$pid)"
     echo "================================"
    else
     echo "================================="
         echo "[Start Failed]"
     echo "================================="
    fi
}

#    
#   kill -15 pid        ,        shutdownhook    
stop() {
    getpid

    if [ $pid -ne 0 ]; then
      skill -15 $pid
      echo "================================"
      echo "stoping"
      echo "================================"
   fi
}


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

좋은 웹페이지 즐겨찾기