|
@@ -1,141 +0,0 @@
|
|
|
-#!/bin/sh
|
|
|
-PROCESS_NAME=gihon-rbac
|
|
|
-MAIN_CLASS=com.gihon.component.GihonRbacApplication
|
|
|
-cd `dirname $0`
|
|
|
-BIN_DIR=`pwd`
|
|
|
-#set -x
|
|
|
-#set -e
|
|
|
-PROCESS_HOME=`dirname $BIN_DIR`
|
|
|
-LOG_PATH=$PROCESS_HOME/log
|
|
|
-
|
|
|
-if [ -n "$2" ];then
|
|
|
- PROCESS_NAME=$2;
|
|
|
-fi
|
|
|
-if [ -n "$3" ];then
|
|
|
- MAIN_CLASS=$3;
|
|
|
-fi
|
|
|
-if [ -z "$JAVA_HOME" ];then
|
|
|
- echo "JAVA_HOME NOT SET"
|
|
|
- exit -1
|
|
|
-fi
|
|
|
-
|
|
|
-LIB_DIR=`dirname $PROCESS_HOME`/lib
|
|
|
-JARS="$PROCESS_HOME/prjConf:$PROCESS_HOME/lib/*:"
|
|
|
-
|
|
|
-JARS="$JARS$LIB_DIR/*"
|
|
|
-# only *; *.jar is not support
|
|
|
-#if [ -d $LIB ]; then
|
|
|
-# for i in $LIB/*.jar; do
|
|
|
-# JARS="$JARS":$i
|
|
|
-# done
|
|
|
-#fi
|
|
|
-
|
|
|
-export JARS
|
|
|
-
|
|
|
-if [ ! -d "$BIN_DIR/process/" ];then
|
|
|
- mkdir $BIN_DIR/process
|
|
|
-fi
|
|
|
-if [ ! -d "$PROCESS_HOME/log/" ];then
|
|
|
- mkdir $PROCESS_HOME/log
|
|
|
- touch $PROCESS_HOME/log/console.log
|
|
|
-fi
|
|
|
-
|
|
|
-JAVA_OPTS="-Dprogram.name=$PROCESS_NAME -DPROCESS_HOME=$PROCESS_HOME -Dlog.path=$LOG_PATH -Xms256M -Xmx1G -Duser.timezone=GMT+8 -Dfile.encoding=UTF-8"
|
|
|
-JAVA_OPTS="$JAVA_OPTS -Xloggc:$BIN_DIR/process/gc.vgc -XX:+PrintGCDateStamps"
|
|
|
-
|
|
|
-#进程ID
|
|
|
-jpsid=0
|
|
|
-
|
|
|
-#检测进程
|
|
|
-checkpid(){
|
|
|
- javaps=`jps -lmv|grep $PROCESS_NAME|awk '{print $1}'`
|
|
|
- if [ -n "$javaps" ];then
|
|
|
- jpsid=$javaps
|
|
|
- else
|
|
|
- jpsid=0
|
|
|
- fi
|
|
|
-}
|
|
|
-#启动
|
|
|
-start(){
|
|
|
- checkpid
|
|
|
- if [ $jpsid -ne 0 ]; then
|
|
|
- echo "================================"
|
|
|
- echo "warn: $PROCESS_NAME already started! (pid=$psid)"
|
|
|
- echo "================================"
|
|
|
- else
|
|
|
- echo -n "Starting $PROCESS_NAME ..."
|
|
|
- nohup java -server $JAVA_OPTS -cp $JARS $MAIN_CLASS > $PROCESS_HOME/log/console.log 2>&1 &
|
|
|
- sleep 2
|
|
|
- checkpid
|
|
|
- if [ $jpsid -ne 0 ]; then
|
|
|
- echo "(pid=$jpsid) [OK]"
|
|
|
- else
|
|
|
- echo "[Failed]"
|
|
|
- fi
|
|
|
- fi
|
|
|
-}
|
|
|
-#停止
|
|
|
-stop() {
|
|
|
- checkpid
|
|
|
- if [ $jpsid -ne 0 ]; then
|
|
|
- echo -n "Stopping $PROCESS_NAME ...(pid=$jpsid) "
|
|
|
- kill $1 $jpsid
|
|
|
- if [ $? -eq 0 ]; then
|
|
|
- echo "[OK]"
|
|
|
- else
|
|
|
- echo "[Failed]"
|
|
|
- fi
|
|
|
- sleep 2
|
|
|
- checkpid
|
|
|
- if [ $jpsid -ne 0 ]; then
|
|
|
- stop -9
|
|
|
- fi
|
|
|
- else
|
|
|
- echo "================================"
|
|
|
- echo "warn: $PROCESS_NAME is not running"
|
|
|
- echo "================================"
|
|
|
- fi
|
|
|
-}
|
|
|
-#状态
|
|
|
-status() {
|
|
|
- checkpid
|
|
|
-
|
|
|
- if [ $jpsid -ne 0 ]; then
|
|
|
- echo "$PROCESS_NAME is running! (pid=$jpsid)"
|
|
|
- tail $PROCESS_HOME/log/gihon.log
|
|
|
- else
|
|
|
- echo "$PROCESS_NAME is not running"
|
|
|
- fi
|
|
|
-}
|
|
|
-#帮助信息
|
|
|
-info() {
|
|
|
- echo "************************************************************************"
|
|
|
- echo "JAVA_HOME=$JAVA_HOME"
|
|
|
- echo `java -version`
|
|
|
- echo "gihon service v1.0.0"
|
|
|
- echo "usage: ./boot.sh <command>"
|
|
|
- echo "command = < start|stop|info|restart|status|help >"
|
|
|
- echo "start: start service '$2' and MainClass '$3' in current shell, and in background if succeded with &."
|
|
|
- echo "the program should be execute with root privelage."
|
|
|
- echo "***************************************************************************"
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-case "$1" in
|
|
|
- 'start')
|
|
|
- start
|
|
|
- ;;
|
|
|
- 'stop')
|
|
|
- stop
|
|
|
- ;;
|
|
|
- 'status')
|
|
|
- status
|
|
|
- ;;
|
|
|
- 'restart')
|
|
|
- stop
|
|
|
- start
|
|
|
- ;;
|
|
|
- *)
|
|
|
- info
|
|
|
- ;;
|
|
|
-esac
|