62 lines
1.3 KiB
Bash
62 lines
1.3 KiB
Bash
#!/bin/bash
|
||
|
||
# ZJPB 应用管理脚本
|
||
# 用法: ./manage.sh [start|stop|restart|status|logs]
|
||
|
||
APP_NAME="zjpb"
|
||
APP_DIR="/www/wwwroot/zjpb"
|
||
VENV_DIR="$APP_DIR/venv"
|
||
PID_FILE="$APP_DIR/logs/gunicorn.pid"
|
||
|
||
cd $APP_DIR
|
||
|
||
case "$1" in
|
||
start)
|
||
echo "启动 $APP_NAME..."
|
||
source $VENV_DIR/bin/activate
|
||
gunicorn -c gunicorn_config.py app:app
|
||
echo "$APP_NAME 已启动"
|
||
;;
|
||
|
||
stop)
|
||
echo "停止 $APP_NAME..."
|
||
if [ -f $PID_FILE ]; then
|
||
kill $(cat $PID_FILE)
|
||
echo "$APP_NAME 已停止"
|
||
else
|
||
echo "PID文件不存在,可能未运行"
|
||
fi
|
||
;;
|
||
|
||
restart)
|
||
$0 stop
|
||
sleep 2
|
||
$0 start
|
||
;;
|
||
|
||
status)
|
||
if [ -f $PID_FILE ]; then
|
||
PID=$(cat $PID_FILE)
|
||
if ps -p $PID > /dev/null; then
|
||
echo "$APP_NAME 正在运行 (PID: $PID)"
|
||
else
|
||
echo "$APP_NAME 未运行(但PID文件存在)"
|
||
fi
|
||
else
|
||
echo "$APP_NAME 未运行"
|
||
fi
|
||
;;
|
||
|
||
logs)
|
||
echo "实时查看日志(Ctrl+C退出):"
|
||
tail -f logs/error.log
|
||
;;
|
||
|
||
*)
|
||
echo "用法: $0 {start|stop|restart|status|logs}"
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
exit 0
|