springboot的启动脚本配置

springboot启动与停止的最基本的脚本配置

#!/bin/sh

path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
mode=$1

app_process=`ps -ef | grep "waypal-tracker-server.jar"| grep -v grep`

case "$mode" in
   'start')
        echo "it's ready to start op...."
        if test -n "$app_process"; then
                echo ""
                echo "$app_process"
                echo ""
        else
                cd $path_script   #进入脚本所在目录下,目的是使springboot的config目录生效。
                nohup java -jar $path_script/bin/waypal-tracker-server.jar logPath=$HOME/waypalers.cn/tracker/data > /dev/null 2>&1 &
                cd $path_current

        fi

        echo 'success to start.'
        ;;
   'stop')
        echo "it's ready to check process..."
        if test -n "$app_process"; then
                echo "had find app process informaton"
                echo $app_process | awk '{print ($2)}' | xargs kill -9
        fi
        echo 'success to kill.'
        ;;
    *)
        basename=`basename "$0"`
        echo "Usage: $basename  {start|stop}  [ server options ]"
        exit 1
        ;;
esac
exit 1