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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| #!/bin/bash
APP_HOME=/home/go/src/check_people_gin APP_NAME=checkpeople
case $1 in start) # 开始 PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}') if [ -z "$PID" ] ;then echo "start ${APP_NAME}" nohup ${APP_HOME}/${APP_NAME} > /dev/null 2>&1 & else echo "${APP_NAME} is running" fi ;;
stop) # 停止 PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}') if [ -z "$PID" ] ;then echo "${APP_NAME} is not running" else echo "stop ${APP_NAME}" kill -9 $PID fi ;;
restart) # 重启 PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}') if [ -z "$PID" ] ;then echo "start ${APP_NAME}" nohup ${APP_HOME}/${APP_NAME} > /dev/null 2>&1 & else echo "stop ${APP_NAME}" kill -9 $PID echo "start ${APP_NAME}" nohup ${APP_HOME}/${APP_NAME} > /dev/null 2>&1 & fi ;;
logs) # 日志 tail -f ${APP_HOME}/logs/checkpeople.log ;;
status) # 状态 PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}') if [ -z "$PID" ] ;then echo "${APP_NAME} is not running" else echo "${APP_NAME} is running, pid $PID" fi ;;
esac
|