diff --git a/.DS_Store b/.DS_Store index 6cd3efb..34a17da 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/__pycache__/BI.cpython-312.pyc b/__pycache__/BI.cpython-312.pyc deleted file mode 100644 index a7ad2cf..0000000 Binary files a/__pycache__/BI.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/CTime.cpython-312.pyc b/__pycache__/CTime.cpython-312.pyc deleted file mode 100644 index bb87c58..0000000 Binary files a/__pycache__/CTime.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/ChanBIZS.cpython-312.pyc b/__pycache__/ChanBIZS.cpython-312.pyc deleted file mode 100644 index 4c226f2..0000000 Binary files a/__pycache__/ChanBIZS.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/ChanLun_Classifier.cpython-312.pyc b/__pycache__/ChanLun_Classifier.cpython-312.pyc deleted file mode 100644 index b79fd69..0000000 Binary files a/__pycache__/ChanLun_Classifier.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/Enum.cpython-312.pyc b/__pycache__/Enum.cpython-312.pyc deleted file mode 100644 index eeca940..0000000 Binary files a/__pycache__/Enum.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/KLC.cpython-312.pyc b/__pycache__/KLC.cpython-312.pyc deleted file mode 100644 index 445115e..0000000 Binary files a/__pycache__/KLC.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/KLU.cpython-312.pyc b/__pycache__/KLU.cpython-312.pyc deleted file mode 100644 index f99936d..0000000 Binary files a/__pycache__/KLU.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/ZS.cpython-312.pyc b/__pycache__/ZS.cpython-312.pyc deleted file mode 100644 index b1c00b6..0000000 Binary files a/__pycache__/ZS.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 1b26654..0000000 Binary files a/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..2931380 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# 缠论分析系统生产环境部署脚本 + +# 显示执行的命令 +set -x + +# 确保脚本在错误时停止 +set -e + +# 项目根目录 +PROJECT_DIR=$(pwd) +echo "项目将部署在: $PROJECT_DIR" + +# 创建虚拟环境 +echo "创建Python虚拟环境..." +python3 -m venv venv +source venv/bin/activate + +# 安装依赖 +echo "安装依赖包..." +pip install --upgrade pip +pip install flask pandas matplotlib ccxt pytz talib-binary gunicorn + +# 安装任何额外的系统依赖 +# sudo apt-get update +# sudo apt-get install -y python3-dev + +# 检查目录结构 +echo "检查目录结构..." +mkdir -p web/templates + +# 创建日志目录 +mkdir -p logs + +# 创建启动脚本 +echo "创建启动脚本..." +cat > start_service.sh << 'EOF' +#!/bin/bash +# 缠论分析系统启动脚本 + +# 项目根目录 +PROJECT_DIR=$(pwd) +cd $PROJECT_DIR + +# 激活虚拟环境 +source venv/bin/activate + +# 启动服务 +cd web +echo "启动缠论分析系统服务..." +gunicorn app:app --bind=0.0.0.0:8123 --workers=4 --timeout=120 --log-level=info --log-file=logs/chanlun.log --daemon + +echo "服务已启动,端口8123" +echo "日志文件位置: $PROJECT_DIR/web/logs/chanlun.log" +EOF + +# 创建停止脚本 +echo "创建停止脚本..." +cat > stop_service.sh << 'EOF' +#!/bin/bash +# 停止缠论分析系统服务 + +echo "停止缠论分析系统服务..." +pkill -f "gunicorn app:app" +echo "服务已停止" +EOF + +# 添加执行权限 +chmod +x start_service.sh +chmod +x stop_service.sh + +# 修改app.py中的调试模式(生产环境应关闭调试模式) +if [ -f web/app.py ]; then + echo "配置app.py为生产环境模式..." + sed -i 's/app.run(debug=True, host='\''0.0.0.0'\'', port=8123)/# 在生产环境中,使用gunicorn启动服务\n# app.run(debug=False, host='\''0.0.0.0'\'', port=8124)/' user_data/Chan/web/app.py +else + echo "警告: 未找到app.py文件" +fi + +echo "部署完成!" +echo "使用 ./start_service.sh 启动服务" +echo "使用 ./stop_service.sh 停止服务" \ No newline at end of file diff --git a/gunicorn_start.sh b/gunicorn_start.sh new file mode 100644 index 0000000..3cc3427 --- /dev/null +++ b/gunicorn_start.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd /path/to/your/project/user_data/Chan/web +source /path/to/your/virtualenv/bin/activate # 如果使用虚拟环境 +exec gunicorn app:app -b 0.0.0.0:8123 --workers=4 --timeout 120 \ No newline at end of file diff --git a/start_service.sh b/start_service.sh new file mode 100644 index 0000000..ddacc45 --- /dev/null +++ b/start_service.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# 缠论分析系统启动脚本 + +# 项目根目录 +PROJECT_DIR=$(pwd) +cd $PROJECT_DIR + +# 激活虚拟环境 +source venv/bin/activate + +# 启动服务 +cd web +echo "启动缠论分析系统服务..." +gunicorn app:app --bind=0.0.0.0:8123 --workers=4 --timeout=120 --log-level=info --log-file=logs/chanlun.log --daemon + +echo "服务已启动,端口8123" +echo "日志文件位置: $PROJECT_DIR/web/logs/chanlun.log" \ No newline at end of file diff --git a/system/chanlun.service b/system/chanlun.service new file mode 100644 index 0000000..cf0742b --- /dev/null +++ b/system/chanlun.service @@ -0,0 +1,14 @@ +[Unit] +Description=Chan Lun Trading Analysis +After=network.target + +[Service] +User=your_username +Group=your_groupname +WorkingDirectory=/path/to/your/project/user_data/Chan/web +ExecStart=/path/to/your/project/gunicorn_start.sh +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/system/readme b/system/readme new file mode 100644 index 0000000..03439a7 --- /dev/null +++ b/system/readme @@ -0,0 +1,12 @@ +# copy chanlun.service to: +/etc/systemd/system/chanlun.service +# run command: +sudo systemctl daemon-reload +sudo systemctl enable chanlun +sudo systemctl start chanlun + +# check status: +sudo systemctl status chanlun + +# check logs: +sudo journalctl -u chanlun -f \ No newline at end of file