1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /usr/bin/env bash

APP_HOME=/data/server/app0
APP_NAME=app0
PID_FILE=/var/run/app0.pid

startApp(){
    cd ${APP_HOME}
    nohup java -jar ${APP_NAME}.jar > log 2>&1 &
    echo $! > ${PID_FILE};
}

stopApp(){
    kill `cat ${PID_FILE}`
}

case $1 in
    start)
        startApp
        ;;
    stop)
        stopApp
        ;;
    restart)
        stopApp
        startApp
        ;;
    *)
        echo "usage: wrapper {start|stop|restart}" ;;
esac
exit 0