From fd3cdf8033af9f5750e66f609085471d7f54e921 Mon Sep 17 00:00:00 2001 From: yyhuni Date: Fri, 19 Dec 2025 19:02:43 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=BF=9C=E7=A8=8Bworker=208888?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/engine/services/task_distributor.py | 4 ++-- docker/scripts/setup-swap.sh | 10 +++++----- install.sh | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/apps/engine/services/task_distributor.py b/backend/apps/engine/services/task_distributor.py index ce13d1bb..1b666ba1 100644 --- a/backend/apps/engine/services/task_distributor.py +++ b/backend/apps/engine/services/task_distributor.py @@ -232,9 +232,9 @@ class TaskDistributor: network_arg = f"--network {settings.DOCKER_NETWORK_NAME}" server_url = f"http://server:{settings.SERVER_PORT}" else: - # 远程:无需指定网络,使用公网地址 + # 远程:通过 Nginx 反向代理访问(HTTPS,不直连 8888 端口) network_arg = "" - server_url = f"http://{settings.PUBLIC_HOST}:{settings.SERVER_PORT}" + server_url = f"https://{settings.PUBLIC_HOST}" # 挂载路径(所有节点统一使用固定路径) host_results_dir = settings.HOST_RESULTS_DIR # /opt/xingrin/results diff --git a/docker/scripts/setup-swap.sh b/docker/scripts/setup-swap.sh index 466c5e10..c5690957 100755 --- a/docker/scripts/setup-swap.sh +++ b/docker/scripts/setup-swap.sh @@ -26,7 +26,7 @@ fi # 检查是否已有交换分区 CURRENT_SWAP_KB=$(grep SwapTotal /proc/meminfo | awk '{print $2}') -CURRENT_SWAP_GB=$((CURRENT_SWAP_KB / 1024 / 1024)) +CURRENT_SWAP_GB=$(awk "BEGIN {printf \"%.0f\", $CURRENT_SWAP_KB / 1024 / 1024}") if [ "$CURRENT_SWAP_GB" -gt 0 ]; then log_warn "系统已有 ${CURRENT_SWAP_GB}GB 交换分区" swapon --show @@ -37,9 +37,9 @@ if [ "$CURRENT_SWAP_GB" -gt 0 ]; then fi fi -# 获取系统内存大小(GB) +# 获取系统内存大小(GB,四舍五入) TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') -TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024)) +TOTAL_MEM_GB=$(awk "BEGIN {printf \"%.0f\", $TOTAL_MEM_KB / 1024 / 1024}") # 确定交换分区大小 if [ -n "$1" ]; then @@ -56,8 +56,8 @@ SWAP_FILE="/swapfile_xingrin" log_info "系统内存: ${TOTAL_MEM_GB}GB" log_info "将创建 ${SWAP_SIZE_GB}GB 交换分区: $SWAP_FILE" -# 检查磁盘空间 -AVAILABLE_GB=$(df / | tail -1 | awk '{print int($4/1024/1024)}') +# 检查磁盘空间(向下取整,保守估计) +AVAILABLE_GB=$(df / | tail -1 | awk '{printf "%.0f", $4/1024/1024}') if [ "$AVAILABLE_GB" -lt "$SWAP_SIZE_GB" ]; then log_error "磁盘空间不足!可用: ${AVAILABLE_GB}GB,需要: ${SWAP_SIZE_GB}GB" exit 1 diff --git a/install.sh b/install.sh index d6693c78..26ae8f16 100755 --- a/install.sh +++ b/install.sh @@ -282,13 +282,13 @@ fi # 交换分区配置(仅 Linux) # ============================================================================== if [[ "$OSTYPE" == "linux-gnu"* ]]; then - # 获取当前内存大小(GB,纯 bash 算术) + # 获取当前内存大小(GB,四舍五入) TOTAL_MEM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') - TOTAL_MEM_GB=$((TOTAL_MEM_KB / 1024 / 1024)) + TOTAL_MEM_GB=$(awk "BEGIN {printf \"%.0f\", $TOTAL_MEM_KB / 1024 / 1024}") - # 获取当前交换分区大小(GB) + # 获取当前交换分区大小(GB,四舍五入) CURRENT_SWAP_KB=$(grep SwapTotal /proc/meminfo | awk '{print $2}') - CURRENT_SWAP_GB=$((CURRENT_SWAP_KB / 1024 / 1024)) + CURRENT_SWAP_GB=$(awk "BEGIN {printf \"%.0f\", $CURRENT_SWAP_KB / 1024 / 1024}") # 推荐交换分区大小(与内存相同,最小1G,最大8G) RECOMMENDED_SWAP=$TOTAL_MEM_GB