重构:统一 Python 部署脚本并修复编码问题
- 新增 deploy.py 统一部署脚本(调用各子目录 .py 脚本) - 保留 deploy.sh 统一部署脚本(调用各子目录 .sh 脚本) - 删除旧的 deploy-all.sh / deploy-domain.sh / deploy-to-prod.sh - 修复 Windows GBK 编码导致的 UnicodeDecodeError/UnicodeEncodeError - 修复 nginx 远程目录自动创建 - 移除 backend-single/deploy.py 和 web/deploy.py 中的 emoji 字符 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+10
-4
@@ -5,11 +5,17 @@
|
||||
使用方法: python deploy.py
|
||||
"""
|
||||
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
# 强制 stdout/stderr 使用 UTF-8 编码,避免 Windows GBK 编码错误
|
||||
if hasattr(sys.stdout, 'buffer'):
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
||||
|
||||
# 服务器配置
|
||||
SERVER_IP = "101.200.208.45"
|
||||
USERNAME = "root"
|
||||
@@ -29,17 +35,17 @@ class Colors:
|
||||
|
||||
def log_info(msg):
|
||||
"""打印信息日志"""
|
||||
print(f"{Colors.GREEN}✅{Colors.RESET} {msg}")
|
||||
print(f"{Colors.GREEN}[OK]{Colors.RESET} {msg}")
|
||||
|
||||
|
||||
def log_error(msg):
|
||||
"""打印错误日志"""
|
||||
print(f"{Colors.RED}❌{Colors.RESET} {msg}")
|
||||
print(f"{Colors.RED}[ERR]{Colors.RESET} {msg}")
|
||||
|
||||
|
||||
def log_step(msg):
|
||||
"""打印步骤日志"""
|
||||
print(f"📦 {msg}")
|
||||
print(f"[STEP] {msg}")
|
||||
|
||||
|
||||
def run_command(cmd, cwd=None, shell=True, capture=True, timeout=None):
|
||||
@@ -160,7 +166,7 @@ def deploy():
|
||||
# 上传文件
|
||||
if upload_files():
|
||||
log_info("部署完成!")
|
||||
print(f"📱 访问地址: http://{SERVER_IP}/emotion-museum/")
|
||||
print(f"访问地址: http://{SERVER_IP}/emotion-museum/")
|
||||
else:
|
||||
log_error("部署失败,请检查:")
|
||||
print("1. 服务器IP地址是否正确")
|
||||
|
||||
Reference in New Issue
Block a user