feat:完善项目
This commit is contained in:
72
server.sh
Normal file
72
server.sh
Normal file
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# date
|
||||
# 替换为你自己的执行程序
|
||||
APP_NAME=main
|
||||
# 项目的路径(替换成项目的路径)
|
||||
PROJECT_LOCATION=/home/www/SciencesServer
|
||||
usage() {
|
||||
echo "Usage: sh 执行脚本.sh [start|stop|restart|status]"
|
||||
exit 1
|
||||
}
|
||||
is_exist(){
|
||||
pid=`ps -ef|grep ./$APP_NAME|grep -v grep|awk '{print $2}' `
|
||||
#如果不存在返回1,存在返回0
|
||||
if [ -z "${pid}" ]; then
|
||||
#return 1
|
||||
proct=1
|
||||
else
|
||||
#return 0
|
||||
proct=0
|
||||
fi
|
||||
}
|
||||
start(){
|
||||
is_exist
|
||||
if [ $proct -eq 0 ]; then
|
||||
echo "${APP_NAME} is already running. pid=${pid} ."
|
||||
else
|
||||
cd ${PROJECT_LOCATION}
|
||||
#nohup java -Xms256m -Xmx256m -jar $APP_NAME > /dev/null 2>&1 &
|
||||
nohup ./$APP_NAME > /dev/null 2>&1 &
|
||||
echo "${APP_NAME} is start"
|
||||
fi
|
||||
}
|
||||
stop(){
|
||||
is_exist
|
||||
if [ $proct -eq 0 ]; then
|
||||
cd ${PROJECT_LOCATION}
|
||||
kill -9 $pid
|
||||
echo "${APP_NAME} is stop"
|
||||
else
|
||||
echo "${APP_NAME} is not running"
|
||||
fi
|
||||
}
|
||||
status(){
|
||||
is_exist
|
||||
if [ $proct -eq 0 ]; then
|
||||
echo "${APP_NAME} is running. pid is ${pid}"
|
||||
else
|
||||
echo "${APP_NAME} is not running."
|
||||
fi
|
||||
}
|
||||
restart(){
|
||||
stop
|
||||
start
|
||||
}
|
||||
# 根据输入参数,选择执行对应方法,不输入则执行使用说明
|
||||
case "$1" in
|
||||
"start")
|
||||
start
|
||||
;;
|
||||
"stop")
|
||||
stop
|
||||
;;
|
||||
"status")
|
||||
status
|
||||
;;
|
||||
"restart")
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user