Files
zjpb.net/manage.sh.backup
2025-12-31 01:37:27 +08:00

62 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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