Initial commit
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 确保安装了虚拟环境工具
|
||||
echo "检查并安装虚拟环境工具..."
|
||||
sudo apt update
|
||||
sudo apt install -y python3-venv python3-full
|
||||
|
||||
# 创建日志目录(如果不存在)
|
||||
mkdir -p logs
|
||||
|
||||
# 创建虚拟环境(如果不存在)
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "创建虚拟环境..."
|
||||
python3 -m venv venv
|
||||
fi
|
||||
|
||||
# 激活虚拟环境
|
||||
echo "激活虚拟环境..."
|
||||
source venv/bin/activate
|
||||
|
||||
# 安装依赖
|
||||
echo "安装依赖..."
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 使用gunicorn启动应用
|
||||
echo "启动应用..."
|
||||
venv/bin/gunicorn -w 4 -b 0.0.0.0:8123 --access-logfile logs/access.log --error-logfile logs/error.log --daemon app:app
|
||||
|
||||
echo "服务已启动在 http://服务器IP:8123"
|
||||
echo "查看进程状态: ps aux | grep gunicorn"
|
||||
echo "停止服务: ./stop_venv.sh"
|
||||
Reference in New Issue
Block a user