2 Star 2 Fork 0

黄朝勋 / 知识库

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
run.sh 1.65 KB
一键复制 编辑 原始数据 按行查看 历史
黄朝勋 提交于 2022-12-22 11:07 . 升级
#!/bin/bash
APP_NAME=mm-wiki
INSTALL_NAME=install
ROOT_DIR=$(cd "$(dirname "$0")";pwd)
INSTALL_DIR=$(cd "$(dirname "$0")/install";pwd)
APP_FILE=${ROOT_DIR}/${APP_NAME}
INSTALL_FILE=${INSTALL_DIR}/${INSTALL_NAME}
PID_FILE=${ROOT_DIR}/logs/${APP_NAME}.pid
LOG_FILE=${ROOT_DIR}/logs/${APP_NAME}.log
function install() {
chmod +x ${INSTALL_FILE}
${INSTALL_FILE}
return 0
}
function check_pid() {
if [[ -f ${PID_FILE} ]];then
pid=`cat ${PID_FILE}`
if [[ -n ${pid} ]]; then
res=`ps -p ${pid}|grep -v "PID TTY" |wc -l`
return `echo ${res}`
fi
fi
return 0
}
function start() {
check_pid
run_res=$?
if [[ ${run_res} -gt 0 ]];then
echo -n "${APP_NAME} is running already, pid="
cat ${PID_FILE}
return 1
fi
chmod +x ${APP_FILE}
nohup ${APP_FILE} &> ${LOG_FILE} &
echo $! > ${PID_FILE}
echo "${APP_NAME} start running, pid=$!"
}
function stop() {
pid=`cat ${PID_FILE}`
kill ${pid}
echo "${APP_NAME} stop."
}
function restart() {
pid=`cat ${PID_FILE}`
stop
start
}
function status() {
check_pid
run_res=$?
if [[ ${run_res} -gt 0 ]];then
echo "status: start"
else
echo "status: stop"
fi
}
function help() {
echo "$0 install|start|stop|restart|status|pid"
}
function pid() {
cat ${PID_FILE}
}
if [[ "$1" == "" ]]; then
help
elif [[ "$1" == "install" ]];then
install
elif [[ "$1" == "stop" ]];then
stop
elif [[ "$1" == "start" ]];then
start
elif [[ "$1" == "restart" ]];then
restart
elif [[ "$1" == "status" ]];then
status
elif [[ "$1" == "pid" ]];then
pid
else
help
fi
Go
1
https://gitee.com/xiaobuxia/wiki.git
git@gitee.com:xiaobuxia/wiki.git
xiaobuxia
wiki
知识库
master

搜索帮助