mirror of http://192.168.10.4:8099/sane/dpkg.git
90 lines
1.4 KiB
Bash
Executable File
90 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
|
|
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
echo "current dir $DIR"
|
|
BASE_DIR="$DIR"
|
|
export LD_LIBRARY_PATH="$DIR"
|
|
APP_NAME=HwWebService
|
|
|
|
APP_PATH="$BASE_DIR/HwWebService"
|
|
echo "APP_PATH = $APP_PATH"
|
|
LIB_PARH="$BASE_DIR/libhwdriver.so"
|
|
echo "LIB_PARH = $LIB_PARH"
|
|
|
|
#userage
|
|
usage() {
|
|
echo "Usage: sh script.sh [start|stop|restart|status]"
|
|
exit 1
|
|
}
|
|
is_exist(){
|
|
if [ ! -f $BASE_DIR/HwWebService ]; then
|
|
return 1
|
|
else
|
|
pid=`ps -ef | grep "HGWebService" | grep -v grep | awk '{print $2}'`
|
|
echo "PID: $pid"
|
|
appNum=`ps -ef|awk '{print $2}'|grep -c -e "^${pid}\$"`
|
|
echo appNum $appNum
|
|
if [ ${appNum} -gt 0 ]; then
|
|
return 0
|
|
else
|
|
rm -rf $BASE_DIR/HwWebService.pid >/dev/null 2>&1 &
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
#start server
|
|
start(){
|
|
is_exist
|
|
if [ $? -eq "0" ]; then
|
|
echo "${APP_NAME} is already running. pid=${pid} ."
|
|
else
|
|
echo "APP_PATH: $APP_PATH"
|
|
echo "LIB_PATH: $LIB_PARH"
|
|
"$DIR"/HwWebService &
|
|
fi
|
|
}
|
|
#stop webserver
|
|
stop(){
|
|
is_exist
|
|
if [ $? -eq "0" ]; then
|
|
kill -9 $pid
|
|
rm -rf $BASE_DIR/application.pid >/dev/null 2>&1 &
|
|
else
|
|
echo "${APP_NAME} is not running"
|
|
fi
|
|
}
|
|
#running status
|
|
status(){
|
|
is_exist
|
|
if [ $? -eq "0" ]; then
|
|
echo "${APP_NAME} is running. Pid is ${pid}"
|
|
else
|
|
echo "${APP_NAME} is NOT running."
|
|
fi
|
|
}
|
|
#restart server
|
|
restart(){
|
|
stop
|
|
start
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
"start")
|
|
start
|
|
;;
|
|
"stop")
|
|
stop
|
|
;;
|
|
"status")
|
|
status
|
|
;;
|
|
"restart")
|
|
restart
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|